]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: assert on invalid base in resolve_protocol_conflict()
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 28 Jan 2016 12:03:03 +0000 (13:03 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 31 Jan 2016 22:43:35 +0000 (23:43 +0100)
We already have similar code in the tree, we shouldn't see bases over
transport yet.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c

index eb442d54811a573768245e3e2809889b9d82cdba..b70ff07c85dfad5a3804bc25a48d85637fb4919e 100644 (file)
@@ -392,6 +392,7 @@ static int resolve_protocol_conflict(struct eval_ctx *ctx,
                                     struct expr *payload)
 {
        enum proto_bases base = payload->payload.base;
+       const struct proto_desc *next;
        struct stmt *nstmt = NULL;
        int link, err;
 
@@ -402,18 +403,17 @@ static int resolve_protocol_conflict(struct eval_ctx *ctx,
                        return err;
        }
 
-       if (base < PROTO_BASE_MAX) {
-               const struct proto_desc *next = ctx->pctx.protocol[base + 1].desc;
+       assert(base < PROTO_BASE_MAX);
+       next = ctx->pctx.protocol[base + 1].desc;
 
-               if (payload->payload.desc == next) {
-                       ctx->pctx.protocol[base + 1].desc = NULL;
-                       ctx->pctx.protocol[base].desc = next;
-                       ctx->pctx.protocol[base].offset += desc->length;
-                       payload->payload.offset += desc->length;
-                       return 0;
-               } else if (next) {
-                       return 1;
-               }
+       if (payload->payload.desc == next) {
+               ctx->pctx.protocol[base + 1].desc = NULL;
+               ctx->pctx.protocol[base].desc = next;
+               ctx->pctx.protocol[base].offset += desc->length;
+               payload->payload.offset += desc->length;
+               return 0;
+       } else if (next) {
+               return 1;
        }
 
        link = proto_find_num(desc, payload->payload.desc);