]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: suppress format truncation warning 4062/head
authorVictor Julien <victor@inliniac.net>
Fri, 19 Jul 2019 20:16:33 +0000 (22:16 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Jul 2019 20:16:55 +0000 (22:16 +0200)
  CC       source-netmap.o
source-netmap.c: In function ‘NetmapOpen’:
source-netmap.c:327:56: error: ‘%s’ directive output may be truncated writing up to 15 bytes into a region of size between 10 and 57 [-Werror=format-truncation=]
         snprintf(devname, sizeof(devname), "netmap:%s%s%s",
                                                        ^~
                 ns->iface, strlen(optstr) ? "/" : "", optstr);
                                                       ~~~~~~
source-netmap.c:327:9: note: ‘snprintf’ output 8 or more bytes (assuming 70) into a destination of size 64
         snprintf(devname, sizeof(devname), "netmap:%s%s%s",
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ns->iface, strlen(optstr) ? "/" : "", optstr);
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source-netmap.c:330:59: error: ‘%s’ directive output may be truncated writing up to 15 bytes into a region of size between 8 and 55 [-Werror=format-truncation=]
         snprintf(devname, sizeof(devname), "netmap:%s-%d%s%s",
                                                           ^~
                 ns->iface, ring, strlen(optstr) ? "/" : "", optstr);
                                                             ~~~~~~
source-netmap.c:330:9: note: ‘snprintf’ output 10 or more bytes (assuming 72) into a destination of size 64
         snprintf(devname, sizeof(devname), "netmap:%s-%d%s%s",
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ns->iface, ring, strlen(optstr) ? "/" : "", optstr);
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source-netmap.c:316:54: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
         snprintf(devname, sizeof(devname), "%s}%d%s%s",
                                                      ^
source-netmap.c:316:9: note: ‘snprintf’ output 3 or more bytes (assuming 65) into a destination of size 64
         snprintf(devname, sizeof(devname), "%s}%d%s%s",
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 ns->iface, ring, strlen(optstr) ? "/" : "", optstr);
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Gcc 8 with -Wformat-truncation=1

src/source-netmap.c

index 210aabf3e356f9907153733a632c789dd176604a..3cea7dc691f09bba7f4afbf40437fb778b14220e 100644 (file)
@@ -311,7 +311,7 @@ static int NetmapOpen(NetmapIfaceSettings *ns,
 retry:
     snprintf(optstr, sizeof(optstr), "%s%s%s", opt_z, opt_x, direction == 0 ? opt_R : opt_T);
 
-    char devname[64];
+    char devname[128];
     if (strncmp(ns->iface, "netmap:", 7) == 0) {
         snprintf(devname, sizeof(devname), "%s}%d%s%s",
                 ns->iface, ring, strlen(optstr) ? "/" : "", optstr);