]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
exhtdr: pacify compiler warning
authorFlorian Westphal <fw@strlen.de>
Thu, 13 Jul 2017 14:02:31 +0000 (16:02 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 13 Jul 2017 15:40:13 +0000 (17:40 +0200)
gcc 7.1.1 complains:

exthdr.c:41:31: warning: ā€˜%d’ directive output may be truncated writing between 1 and 8 bytes into a region of size 3 [-Wformat-truncation=]
    snprintf(buf, sizeof buf, "%d", offset);
                               ^~
This warning is incorrect, as offset is limited by tcp option ranges,
but gcc doesn't know this. Increase buffer to avoid the warning.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/exthdr.c

index a678115b692aa426ff33a0b387efe889cd81b6b3..a412025c9a486f8181c9d91357228c812f5e5562 100644 (file)
@@ -30,7 +30,7 @@ static void exthdr_expr_print(const struct expr *expr, struct output_ctx *octx)
                 * multiplicator
                 */
                unsigned int offset = expr->exthdr.offset / 64;
-               char buf[3] = {0};
+               char buf[9] = {0};
 
                if (expr->exthdr.flags & NFT_EXTHDR_F_PRESENT) {
                        printf("tcp option %s", expr->exthdr.desc->name);