Skip to contentSkip to conversation

payload: don't decode past last valid template

PATCH In review Florian Westphal 2 participants 2 messages Feb 15, 2018 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 payload: don't decode past last valid template

When trying to decode payload header fields, be sure to bail out when having exhausted all available templates.

Otherwise, we allocate invalid payload expressions (no dataype, header length of 0) and then crash when trying to print them.

---
 src/payload.c | 4 ++++
 1 file changed, 4 insertions(+)
src/payload.c +4 -0
index 60090accbcd8..63c9f7157e4e 100644
@@ -618,6 +618,10 @@ void payload_expr_expand(struct list_head *list, struct expr *expr,
 
 	for (i = 1; i < array_size(desc->templates); i++) {
 		tmpl = &desc->templates[i];
+
+		if (tmpl->len == 0)
+			break;
+
 		if (tmpl->offset != expr->payload.offset)
 			continue;
 
Signature · 1 line
2.16.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Florian Westphal

When trying to decode payload header fields, be sure to bail out when having exhausted all available templates.

Otherwise, we allocate invalid payload expressions (no dataype, header length of 0) and then crash when trying to print them.