diff options
author | Florian Westphal <fw@strlen.de> | 2019-09-16 15:44:48 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2019-09-16 15:44:48 +0200 |
commit | 03a4a20b675fb728866b51864b885714551176d3 (patch) | |
tree | 423a8d236c612c6f19678b22a5d8729f8ebc0cd0 /libiptc | |
parent | 7f97513ae2532c62854084e914a517ea79ad3b31 (diff) |
libiptc: silence two comiler warnings
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 <fw@strlen.de>
Diffstat (limited to 'libiptc')
-rw-r--r-- | libiptc/libiptc.c | 4 |
1 files changed, 2 insertions, 2 deletions
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); |