From: Jeremy Sowden Date: Fri, 17 Mar 2023 09:16:43 +0000 (+0100) Subject: evaluate: don't eval unary arguments X-Git-Tag: v1.0.6.1~300 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b239b7419cb13a40f285384722104be04d839f26;p=thirdparty%2Fnftables.git evaluate: don't eval unary arguments 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 Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/evaluate.c b/src/evaluate.c index 9cad7890..b3fd14c1 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -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);