Skip to contentSkip to conversation

netlink_delinearize: prune implicit binop before payload_match_postprocess()

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Feb 1, 2016 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netlink_delinearize: prune implicit binop before payload_match_postprocess()

payload_match_postprocess() expects a relational with payload of his lhs and value on the rhs.

Moreover, payload_match_expand() releases the previous expression so valgrind reports an use-after-free when pruning the implicit binop.

Fix this by calling payload_match_postprocess() in first place.

---
 src/netlink_delinearize.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
src/netlink_delinearize.c +2 -3
index 7d94f30..ae6abb0 100644
@@ -1229,13 +1229,12 @@ static void binop_postprocess(struct rule_pp_ctx *ctx, struct expr *expr)
 			value->len = payload->len;
 		}
 
-		payload_match_postprocess(ctx, expr, payload);
-
 		assert(expr->left->ops->type == EXPR_BINOP);
-
 		assert(binop->left == payload);
 		expr->left = expr_get(payload);
 		expr_free(binop);
+
+		payload_match_postprocess(ctx, expr, payload);
 	}
 }
 
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 5 lines · Pablo Neira Ayuso

payload_match_postprocess() expects a relational with payload of his lhs and value on the rhs.

Moreover, payload_match_expand() releases the previous expression so valgrind reports an use-after-free when pruning the implicit binop.

Right, my bad. Please push this fix, thanks!