]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: don't eval unary arguments
authorJeremy Sowden <jeremy@azazel.net>
Fri, 17 Mar 2023 09:16:43 +0000 (10:16 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 22 Jan 2025 21:10:05 +0000 (22:10 +0100)
commit 6bea6864b799905c8cc5f7a3f9488c88e219c481 upstream.

When a unary expression is inserted to implement a byte-order
conversion, the expression being converted has already been evaluated
and so `expr_evaluate_unary` doesn't need to do so.

This is required by {ct|meta} statements with bitwise operations, which
might result in byteorder conversion of the expression.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c

index 9cad7890ef9aa66f3bc726246e6afd5306a40880..b3fd14c1c2efdec8e6fa4d070b831533664076c8 100644 (file)
@@ -1103,12 +1103,10 @@ static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **expr)
  */
 static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr)
 {
-       struct expr *unary = *expr, *arg;
+       struct expr *unary = *expr, *arg = unary->arg;
        enum byteorder byteorder;
 
-       if (expr_evaluate(ctx, &unary->arg) < 0)
-               return -1;
-       arg = unary->arg;
+       /* unary expression arguments has already been evaluated. */
 
        assert(!expr_is_constant(arg));
        assert(expr_basetype(arg)->type == TYPE_INTEGER);