[PATCH libnetfilter_conntrack] expect: parse_mnl: fix gcc compile warning

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

 



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);
      |    ~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/expect/parse_mnl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/expect/parse_mnl.c b/src/expect/parse_mnl.c
index e7bbc16cadac..091a8ae0cf84 100644
--- a/src/expect/parse_mnl.c
+++ b/src/expect/parse_mnl.c
@@ -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]) {
-- 
2.11.0




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

  Powered by Linux