From: Florian Westphal Date: Mon, 1 Feb 2016 11:02:36 +0000 (+0100) Subject: meta: fix error checks in tc handle parser X-Git-Tag: v0.6~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5229aba55d8622ef12377f0a59827a709338270;p=thirdparty%2Fnftables.git meta: fix error checks in tc handle parser 'meta priority foobar' did not return an error -- instead we used min/max values with undefined content. Signed-off-by: Florian Westphal Acked-by: Pablo Neira Ayuso --- diff --git a/src/meta.c b/src/meta.c index 8cbc97456..b8db0f89f 100644 --- a/src/meta.c +++ b/src/meta.c @@ -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;