summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-09-20 16:26:08 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2023-09-25 10:41:45 +0200
commit3d0ce3c19d319a5aae806b617905cfa1ee7f87f4 (patch)
tree42aea692fdf0aeec5d9b0b8513345ebcda04158c /include
parent10373f0936cd35de107d9e45e4151d98f9ca306f (diff)
expression: cleanup expr_ops_by_type() and handle u32 input
Make fewer assumptions about the underlying integer type of the enum. Instead, be clear about where we have an untrusted uint32_t from netlink and an enum. Rename expr_ops_by_type() to expr_ops_by_type_u32() to make this clearer. Later we might make the enum as packed, when this starts to matter more. Also, only the code path expr_ops() wants strict validation and assert against valid enum values. Move the assertion out of __expr_ops_by_type(). Then expr_ops_by_type_u32() does not need to duplicate the handling of EXPR_INVALID. We still need to duplicate the check against EXPR_MAX, to ensure that the uint32_t value can be cast to an enum value. [ Remove cast on EXPR_MAX. --pablo ] Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r--include/expression.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/expression.h b/include/expression.h
index 469f41ec..aede223d 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -189,7 +189,7 @@ struct expr_ops {
};
const struct expr_ops *expr_ops(const struct expr *e);
-const struct expr_ops *expr_ops_by_type(enum expr_types etype);
+const struct expr_ops *expr_ops_by_type_u32(uint32_t value);
/**
* enum expr_flags