From 03a4a20b675fb728866b51864b885714551176d3 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 16 Sep 2019 15:44:48 +0200 Subject: libiptc: silence two comiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit avoid hyptothetical truncation by leaving space for triling zero byte. silcences: In file included from libip4tc.c:113: libiptc.c: In function ‘iptcc_alloc_chain_head’: libiptc.c:163:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] 163 | strncpy(c->name, name, TABLE_MAXNAMELEN); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libiptc.c: In function ‘iptc_rename_chain’: libiptc.c:2388:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] 2388 | strncpy(c->name, newname, sizeof(IPT_CHAINLABEL)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Florian Westphal --- libiptc/libiptc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libiptc/libiptc.c') diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index ee2b8521..58882015 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -160,7 +160,7 @@ static struct chain_head *iptcc_alloc_chain_head(const char *name, int hooknum) return NULL; memset(c, 0, sizeof(*c)); - strncpy(c->name, name, TABLE_MAXNAMELEN); + strncpy(c->name, name, TABLE_MAXNAMELEN - 1); c->hooknum = hooknum; INIT_LIST_HEAD(&c->rules); @@ -2385,7 +2385,7 @@ int TC_RENAME_CHAIN(const IPT_CHAINLABEL oldname, iptcc_chain_index_delete_chain(c, handle); /* Change the name of the chain */ - strncpy(c->name, newname, sizeof(IPT_CHAINLABEL)); + strncpy(c->name, newname, sizeof(IPT_CHAINLABEL) - 1); /* Insert sorted into to list again */ iptc_insert_chain(handle, c); -- cgit v1.2.3