]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: fix crash if we add an error format rule
authorLiping Zhang <liping.zhang@spreadtrum.com>
Sat, 14 May 2016 12:43:35 +0000 (20:43 +0800)
committerFlorian Westphal <fw@strlen.de>
Sat, 14 May 2016 20:03:22 +0000 (22:03 +0200)
If we add a such nft rule:
  nft add rule filter input ip protocol icmp tcp dport 0

we will always meet the assert condition:
  nft: evaluate.c:536: resolve_protocol_conflict: Assertion `base < (__PROTO_BASE_MAX - 1)' failed.
  Aborted (core dumped)

Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c

index 53f19b29a580c6459ae1b43dc494eeaf8210a63f..c317761fba5136389282c98627a2693903524cd5 100644 (file)
@@ -533,7 +533,7 @@ static int resolve_protocol_conflict(struct eval_ctx *ctx,
                list_add_tail(&nstmt->list, &ctx->stmt->list);
        }
 
-       assert(base < PROTO_BASE_MAX);
+       assert(base <= PROTO_BASE_MAX);
        /* This payload and the existing context don't match, conflict. */
        if (ctx->pctx.protocol[base + 1].desc != NULL)
                return 1;