Skip to contentSkip to conversation

src: invalid read when importing chain name (trace and json)

PATCH New Pablo Neira Ayuso 1 participant 1 message Jun 10, 2019 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 src: invalid read when importing chain name (trace and json)

Fixes 142350f154c7 ("src: invalid read when importing chain name")

---
Accidentally pushed out previous patch, sorry.

 src/netlink.c     | 3 +--
 src/parser_json.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
src/netlink.c +1 -2
index e9779684ac09..7a4312498ce8 100644
@@ -1172,8 +1172,7 @@ static void trace_print_verdict(const struct nftnl_trace *nlt,
 		chain_expr = constant_expr_alloc(&netlink_location,
 						 &string_type,
 						 BYTEORDER_HOST_ENDIAN,
-						 NFT_CHAIN_MAXNAMELEN
-						 * BITS_PER_BYTE,
+						 strlen(chain) * BITS_PER_BYTE,
 						 chain);
 	}
 	expr = verdict_expr_alloc(&netlink_location, verdict, chain_expr);
src/parser_json.c +1 -1
index 081cf5da7f39..ac110f16fe81 100644
@@ -1059,7 +1059,7 @@ static struct expr *json_alloc_chain_expr(const char *chain)
 		return NULL;
 
 	return constant_expr_alloc(int_loc, &string_type, BYTEORDER_HOST_ENDIAN,
-				   NFT_CHAIN_MAXNAMELEN * BITS_PER_BYTE, chain);
+				   strlen(chain) * BITS_PER_BYTE, chain);
 }
 
 static struct expr *json_parse_verdict_expr(struct json_ctx *ctx,
Signature · 1 line
2.11.0