]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
meta: fix error checks in tc handle parser
authorFlorian Westphal <fw@strlen.de>
Mon, 1 Feb 2016 11:02:36 +0000 (12:02 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 17 Feb 2016 14:53:08 +0000 (15:53 +0100)
'meta priority foobar' did not return an error -- instead
we used min/max values with undefined content.

Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/meta.c

index 8cbc97456e31e0d1d1abc85c0ce6be82a9581039..b8db0f89fe7c8ed3661f05259a0f37ac30c30d00 100644 (file)
@@ -100,17 +100,17 @@ static struct error_record *tchandle_type_parse(const struct expr *sym,
        else if (strcmp(sym->identifier, "none") == 0)
                handle = TC_H_UNSPEC;
        else if (sym->identifier[0] == ':') {
-               if (sscanf(sym->identifier, ":%04x", &handle) < 0)
+               if (sscanf(sym->identifier, ":%04x", &handle) != 1)
                        goto err;
        } else if (sym->identifier[strlen(sym->identifier)-1] == ':') {
-               if (sscanf(sym->identifier, "%04x:", &handle) < 0)
+               if (sscanf(sym->identifier, "%04x:", &handle) != 1)
                        goto err;
 
                handle <<= 16;
        } else {
                uint32_t min, max;
 
-               if (sscanf(sym->identifier, "%04x:%04x", &min, &max) < 0)
+               if (sscanf(sym->identifier, "%04x:%04x", &max, &min) != 2)
                        goto err;
 
                handle = max << 16 | min;