Skip to contentSkip to conversation

expect: parse_mnl: fix gcc compile warning

PATCH New Pablo Neira Ayuso 1 participant 1 message Apr 1, 2020 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 expect: parse_mnl: fix gcc compile warning

parse_mnl.c: In function ‘nfexp_nlmsg_parse’:
parse_mnl.c:142:3: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]

  142 |   strncpy(exp->helper_name,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
  143 |    mnl_attr_get_str(tb[CTA_EXPECT_HELP_NAME]),
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144 |    NFCT_HELPER_NAME_MAX);
      |    ~~~~~~~~~~~~~~~~~~~~~
---
 src/expect/parse_mnl.c | 1 +
 1 file changed, 1 insertion(+)
src/expect/parse_mnl.c +1 -0
index e7bbc16cadac..091a8ae0cf84 100644
@@ -142,6 +142,7 @@ int nfexp_nlmsg_parse(const struct nlmsghdr *nlh, struct nf_expect *exp)
 		strncpy(exp->helper_name,
 			mnl_attr_get_str(tb[CTA_EXPECT_HELP_NAME]),
 			NFCT_HELPER_NAME_MAX);
+		exp->helper_name[NFCT_HELPER_NAME_MAX - 1] = '\0';
 		set_bit(ATTR_EXP_HELPER_NAME, exp->set);
 	}
 	if (tb[CTA_EXPECT_CLASS]) {
Signature · 1 line
2.11.0