Blame SOURCES/0036-evaluate-skip-evaluation-of-datatype-concatenations.patch

bacbc8
From 1c690d0992d3ef1dbb872b1cd65c10161628e9fd Mon Sep 17 00:00:00 2001
bacbc8
From: Pablo Neira Ayuso <pablo@netfilter.org>
bacbc8
Date: Fri, 6 Jul 2018 20:07:54 +0200
bacbc8
Subject: [PATCH] evaluate: skip evaluation of datatype concatenations
bacbc8
bacbc8
These are not really expressions, so there is not value in place. The
bacbc8
expr_evaluate_concat() is called from set_evaluate() to calculate the
bacbc8
total length of the tuple.
bacbc8
bacbc8
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1265
bacbc8
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
bacbc8
(cherry picked from commit 6b00b9537e181eaf630ecaf0d4e56905eb29d87c)
bacbc8
Signed-off-by: Phil Sutter <psutter@redhat.com>
bacbc8
---
bacbc8
 src/evaluate.c | 9 +++++----
bacbc8
 1 file changed, 5 insertions(+), 4 deletions(-)
bacbc8
bacbc8
diff --git a/src/evaluate.c b/src/evaluate.c
bacbc8
index 4656c7566db39..6ab4a3309ad77 100644
bacbc8
--- a/src/evaluate.c
bacbc8
+++ b/src/evaluate.c
bacbc8
@@ -1090,7 +1090,8 @@ static int list_member_evaluate(struct eval_ctx *ctx, struct expr **expr)
bacbc8
 	return err;
bacbc8
 }
bacbc8
 
bacbc8
-static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
bacbc8
+static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr,
bacbc8
+				bool eval)
bacbc8
 {
bacbc8
 	const struct datatype *dtype = ctx->ectx.dtype, *tmp;
bacbc8
 	uint32_t type = dtype ? dtype->type : 0, ntype = 0;
bacbc8
@@ -1111,7 +1112,7 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
bacbc8
 			tmp = concat_subtype_lookup(type, --off);
bacbc8
 		expr_set_context(&ctx->ectx, tmp, tmp->size);
bacbc8
 
bacbc8
-		if (list_member_evaluate(ctx, &i) < 0)
bacbc8
+		if (eval && list_member_evaluate(ctx, &i) < 0)
bacbc8
 			return -1;
bacbc8
 		flags &= i->flags;
bacbc8
 
bacbc8
@@ -1776,7 +1777,7 @@ static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr)
bacbc8
 	case EXPR_BINOP:
bacbc8
 		return expr_evaluate_binop(ctx, expr);
bacbc8
 	case EXPR_CONCAT:
bacbc8
-		return expr_evaluate_concat(ctx, expr);
bacbc8
+		return expr_evaluate_concat(ctx, expr, true);
bacbc8
 	case EXPR_LIST:
bacbc8
 		return expr_evaluate_list(ctx, expr);
bacbc8
 	case EXPR_SET:
bacbc8
@@ -2820,7 +2821,7 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
bacbc8
 
bacbc8
 	if (set->key->len == 0) {
bacbc8
 		if (set->key->ops->type == EXPR_CONCAT &&
bacbc8
-		    expr_evaluate_concat(ctx, &set->key) < 0)
bacbc8
+		    expr_evaluate_concat(ctx, &set->key, false) < 0)
bacbc8
 			return -1;
bacbc8
 
bacbc8
 		if (set->key->len == 0)
bacbc8
-- 
bacbc8
2.21.0
bacbc8