]> The Tcpdump Group git mirrors - libpcap/commit
Address the warnings from -Wformat-truncation.
authorDenis Ovsienko <[email protected]>
Sat, 14 Jul 2018 08:57:25 +0000 (08:57 +0000)
committerDenis Ovsienko <[email protected]>
Sat, 14 Jul 2018 09:01:27 +0000 (09:01 +0000)
commit8cccd1dded942df5760eaf5b5d8faf1938a723f0
tree83970ad75073a2032d2fb6e17a82f1731a141357
parent2743ab9ee055c1500c5e41127dadf2e1be59e812
Address the warnings from -Wformat-truncation.

GCC 7.3.0-16ubuntu3 is concerned about the fact that building one error
message from another can lose some trailing characters, given the sizes
of the input and the output buffers. Use argument-specified precision to
indicate that this effect is intentional. This change squelches the
following warnings:

./pcap.c: In function ‘pcap_open_live’:
./pcap.c:2534:48: warning: ‘%s’ directive output may be truncated writing up to 256 bytes into a region of size 254 [-Wformat-truncation=]
   pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
                                                ^~
In file included from ./pcap-int.h:388:0,
                 from ./pcap.c:79:
./portability.h:125:23: note: ‘snprintf’ output 3 or more bytes (assuming 259) into a destination of size 256
 #define pcap_snprintf snprintf
./pcap.c:2534:3: note: in expansion of macro ‘pcap_snprintf’
   pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
   ^~~~~~~~~~~~~
./pcap.c:2539:52: warning: ‘%s’ directive output may be truncated writing up to 256 bytes into a region of size 252 [-Wformat-truncation=]
   pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", device,
                                                    ^~
In file included from ./pcap-int.h:388:0,
                 from ./pcap.c:79:
./portability.h:125:23: note: ‘snprintf’ output 6 or more bytes (assuming 262) into a destination of size 256
 #define pcap_snprintf snprintf
./pcap.c:2539:3: note: in expansion of macro ‘pcap_snprintf’
   pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", device,
   ^~~~~~~~~~~~~
pcap.c