Skip to contentSkip to conversation

src: Initialize struct stmt in _match and _target functions.

PATCH Applied Varsha Rao 2 participants 3 messages Aug 20, 2017 – Aug 24, 2017 netfilter

lore
Share & tools
lore

Varsha Rao

author
#0 lore raw

PATCH 1/1 src: Initialize struct stmt in _match and _target functions.

Initialize structure stmt with stmt_alloc in netlink_parse_target and netlink_parse_match functions. This patch fixes the warning:

‘stmt’ may be used uninitialized in this function.

---
 src/xt.c | 2 ++
 1 file changed, 2 insertions(+)
src/xt.c +2 -0
index 3bc38ee..9aff414 100644
@@ -143,6 +143,7 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx,
 	m->u.match_size = mt_len + XT_ALIGN(sizeof(struct xt_entry_match));
 	m->u.user.revision = nftnl_expr_get_u32(nle, NFTNL_EXPR_MT_REV);
 
+	stmt = stmt_alloc(loc, NULL);
 	stmt->xt.name = strdup(name);
 	stmt->xt.type = NFT_XT_MATCH;
 	stmt->xt.match = xt_match_clone(mt);
@@ -179,6 +180,7 @@ void netlink_parse_target(struct netlink_parse_ctx *ctx,
 	t->u.user.revision = nftnl_expr_get_u32(nle, NFTNL_EXPR_TG_REV);
 	strcpy(t->u.user.name, tg->name);
 
+	stmt = stmt_alloc(loc, NULL);
 	stmt->xt.name = strdup(name);
 	stmt->xt.type = NFT_XT_TARGET;
 	stmt->xt.target = xt_target_clone(tg);
Signature · 1 line
2.13.5
#1 lore raw
Quoted 15 lines · Varsha Rao

Initialize structure stmt with stmt_alloc in netlink_parse_target and netlink_parse_match functions. This patch fixes the warning:

‘stmt’ may be used uninitialized in this function.

---
 src/xt.c | 2 ++
 1 file changed, 2 insertions(+)
src/xt.c +0 -0
index 3bc38ee..9aff414 100644

src/xt.c void netlink_parse_match(struct netlink_parse_ctx *ctx, · line 146

Quoted 4 lines
src/xt.c +1 -0
@@ -143,6 +143,7 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx,
 	m->u.match_size = mt_len + XT_ALIGN(sizeof(struct xt_entry_match));
 	m->u.user.revision = nftnl_expr_get_u32(nle, NFTNL_EXPR_MT_REV);
 
+	stmt = stmt_alloc(loc, NULL);

this is partially reverting:

http://git.netfilter.org/nftables/commit/?id=bce55916b51ec1a4c23322781e3b0c698ecc9561

Are you 100% this works? How did you test this?

Quoted 14 lines
src/xt.c +1 -0
 	stmt->xt.name = strdup(name);
 	stmt->xt.type = NFT_XT_MATCH;
 	stmt->xt.match = xt_match_clone(mt);
@@ -179,6 +180,7 @@ void netlink_parse_target(struct netlink_parse_ctx *ctx,
 	t->u.user.revision = nftnl_expr_get_u32(nle, NFTNL_EXPR_TG_REV);
 	strcpy(t->u.user.name, tg->name);
 
+	stmt = stmt_alloc(loc, NULL);
 	stmt->xt.name = strdup(name);
 	stmt->xt.type = NFT_XT_TARGET;
 	stmt->xt.target = xt_target_clone(tg);
Signature · 1 line
2.13.5
maintainer Applied
#2 lore raw
In reply to Varsha Rao
Quoted 4 lines · Varsha Rao

Initialize structure stmt with stmt_alloc in netlink_parse_target and netlink_parse_match functions. This patch fixes the warning:

‘stmt’ may be used uninitialized in this function.

Applied, thanks Varsha.