[PATCH iptables 1/4] xtables-compat: fix snprintf truncation warnings

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

 



proto is u16 in the data structure, so this gave:
nft-ipv6.c:422:44: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=]

Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
---
 iptables/nft-ipv4.c | 2 +-
 iptables/nft-ipv6.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index 00dd3e93826b..b779aef5c086 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -459,7 +459,7 @@ static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl)
 	if (cs->fw.ip.proto != 0) {
 		const struct protoent *pent =
 			getprotobynumber(cs->fw.ip.proto);
-		char protonum[strlen("255") + 1];
+		char protonum[sizeof("65535")];
 
 		if (!xlate_find_match(cs, pent->p_name)) {
 			snprintf(protonum, sizeof(protonum), "%u",
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 9867d1ee30b1..1be49dd30027 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -416,7 +416,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl)
 	if (cs->fw6.ipv6.proto != 0) {
 		const struct protoent *pent =
 			getprotobynumber(cs->fw6.ipv6.proto);
-		char protonum[strlen("255") + 1];
+		char protonum[sizeof("65535")];
 
 		if (!xlate_find_match(cs, pent->p_name)) {
 			snprintf(protonum, sizeof(protonum), "%u",
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux