]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables-compat: fix snprintf truncation warnings
authorFlorian Westphal <fw@strlen.de>
Sat, 7 Apr 2018 21:21:23 +0000 (23:21 +0200)
committerFlorian Westphal <fw@strlen.de>
Sun, 8 Apr 2018 21:18:16 +0000 (23:18 +0200)
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@strlen.de>
iptables/nft-ipv4.c
iptables/nft-ipv6.c

index 00dd3e93826b888337299aa1689eb8ccb619c8fd..b779aef5c086babb2aae75b7a9f9b9008a8e3370 100644 (file)
@@ -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",
index 9867d1ee30b157660c88bb464cb7a2906e59a87d..1be49dd3002790eaa366969214d662389a55e04d 100644 (file)
@@ -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",