From: Victor Julien Date: Fri, 19 Jul 2019 20:16:33 +0000 (+0200) Subject: netmap: suppress format truncation warning X-Git-Tag: suricata-5.0.0-rc1~169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4062%2Fhead;p=thirdparty%2Fsuricata.git netmap: suppress format truncation warning 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 --- diff --git a/src/source-netmap.c b/src/source-netmap.c index 210aabf3e3..3cea7dc691 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -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);