aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2018-07-27 09:41:20 +0100
committerDenis Ovsienko <denis@ovsienko.info>2018-07-27 09:43:11 +0100
commit72790d83d4d0280525f60b9dc010c82cc7bdb5c3 (patch)
treea927a0e96686909b591e16f5b8d788ce5324d8d6 /pcap-linux.c
parente7eb3c769d1dfe88e3a0d3ba714d5098ee091d8e (diff)
Address a -Wformat-truncation= compiler warning.
As far as Ubuntu 18.04 kernel headers go, _UTSNAME_RELEASE_LENGTH = = _UTSNAME_VERSION_LENGTH = _UTSNAME_MACHINE_LENGTH = _UTSNAME_LENGTH = = 65. char release[_UTSNAME_RELEASE_LENGTH] contains the kernel version and possibly some suffixes, e.g. "4.15.0-29-generic". For most cases 32 bytes should be enough. char version[_UTSNAME_VERSION_LENGTH] contains the kernel build number, name and date, e.g. "#31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018". This may actually take up to 64 characters. char machine[_UTSNAME_MACHINE_LENGTH] contains the hardware name, e.g. "x86_64". For most cases 16 bytes should be enough. ./pcap-linux.c: In function ‘pcap_handle_packet_mmap’: ./pcap-linux.c:5030:5: warning: ‘%s’ directive output may be truncated writing up to 64 bytes into a region of size between 9 and 160 [-Wformat-truncation=] "corrupted frame on kernel ring mac " ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./pcap-linux.c:5035:5: utsname.machine); ~~~~~~~ ./pcap-linux.c:5032:37: note: format string is defined here "(kernel %s version %s, machine %s)", ^~
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 79bd0ac2..caec4432 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -5029,7 +5029,7 @@ static int pcap_handle_packet_mmap(
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"corrupted frame on kernel ring mac "
"offset %u + caplen %u > frame len %d "
- "(kernel %s version %s, machine %s)",
+ "(kernel %.32s version %s, machine %.16s)",
tp_mac, tp_snaplen, handle->bufsize,
utsname.release, utsname.version,
utsname.machine);