diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-08-14 22:55:41 +0200 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-08-14 23:04:27 +0200 |
commit | 16e2bd5a8c2bd81a60d16030827c0e6f27910957 (patch) | |
tree | f7d43d8a6063bbf7bf480f754627e54c944583be /pcap-usb-linux.c | |
parent | 656445d5d027e32c92b89de6ab870341aa9b4cff (diff) | |
download | libpcap-16e2bd5a8c2bd81a60d16030827c0e6f27910957.tar.gz |
usb-linux: Address a -Wformat-truncation= compiler warning
Moreover:
Fix indent.
The warning was:
./pcap-usb-linux.c: In function 'usb_read_linux':
./pcap-usb-linux.c:903:37: warning: '%s' directive output may be
truncated writing up to 4095 bytes into a region of size 227
[-Wformat-truncation=]
868 | char *string = line;
| ~~~~
......
903 | "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)",
| ^~
./pcap-usb-linux.c:903:7: note: directive argument in the range [-2147483648, 7]
903 | "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./pcap-usb-linux.c:902:3: note: 'snprintf' output between 66 and 4171
bytes into a destination of size 256
902 | snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
903 | "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
904 | string, ret);
| ~~~~~~~~~~~~
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r-- | pcap-usb-linux.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index 98d22de4..436a8452 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -899,9 +899,13 @@ usb_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_cha &cnt); if (ret < 8) { + char string_truncated[181]; + + strncpy(string_truncated, string, sizeof(string_truncated)); + string_truncated[180] = 0; snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)", - string, ret); + "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)", + string_truncated, ret); return -1; } uhdr->id = tag; |