[PATCH nft] src: invalid read when importing chain name (trace and json)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixes: 142350f154c7 ("src: invalid read when importing chain name")
Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
Accidentally pushed out previous patch, sorry.

 src/netlink.c     | 3 +--
 src/parser_json.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index e9779684ac09..7a4312498ce8 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -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);
diff --git a/src/parser_json.c b/src/parser_json.c
index 081cf5da7f39..ac110f16fe81 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -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,
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux