From 82b83ffa0b69cfd8f81d4b122b9d5c020d68ea46 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Sat, 18 Dec 2010 12:34:16 +0100 Subject: The fix of incorrect comparison in check_allowed completed. There was still some other incorrect usage of 'enum ipset_cmd' and 'enum ipset_adt' - corrected. --- src/ipset.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src/ipset.c') diff --git a/src/ipset.c b/src/ipset.c index 04e77a2..65747f6 100644 --- a/src/ipset.c +++ b/src/ipset.c @@ -264,9 +264,27 @@ done: return ret; } +static enum ipset_adt +cmd2cmd(int cmd) +{ + switch(cmd) { + case IPSET_CMD_ADD: + return IPSET_ADD; + case IPSET_CMD_DEL: + return IPSET_DEL; + case IPSET_CMD_TEST: + return IPSET_TEST; + case IPSET_CMD_CREATE: + return IPSET_CREATE; + default: + return 0; + } +} + static void -check_mandatory(const struct ipset_type *type, int cmd) +check_mandatory(const struct ipset_type *type, enum ipset_cmd command) { + enum ipset_adt cmd = cmd2cmd(command); uint64_t flags = ipset_data_flags(ipset_session_data(session)); uint64_t mandatory = type->mandatory[cmd]; const struct ipset_arg *arg = type->args[cmd]; @@ -319,29 +337,14 @@ session_family(void) } } -static int -cmd2cmd(int cmd) -{ - switch(cmd) { - case IPSET_CMD_ADD: - return IPSET_ADD; - case IPSET_CMD_DEL: - return IPSET_DEL; - case IPSET_CMD_TEST: - return IPSET_TEST; - case IPSET_CMD_CREATE: - return IPSET_CREATE; - default: - return 0; - } -} - static void -check_allowed(const struct ipset_type *type, enum ipset_cmd cmd) +check_allowed(const struct ipset_type *type, enum ipset_cmd command) { uint64_t flags = ipset_data_flags(ipset_session_data(session)); - uint64_t allowed = type->full[cmd2cmd(cmd)]; - uint64_t cmdflags = cmd == IPSET_CMD_CREATE ? IPSET_CREATE_FLAGS : IPSET_ADT_FLAGS; + enum ipset_adt cmd = cmd2cmd(command); + uint64_t allowed = type->full[cmd]; + uint64_t cmdflags = command == IPSET_CMD_CREATE + ? IPSET_CREATE_FLAGS : IPSET_ADT_FLAGS; const struct ipset_arg *arg = type->args[cmd]; enum ipset_opt i; @@ -700,7 +703,7 @@ parse_commandline(int argc, char *argv[]) return ret; /* Check mandatory, then allowed options */ - check_mandatory(type, cmd2cmd(cmd)); + check_mandatory(type, cmd); check_allowed(type, cmd); break; -- cgit v1.2.3