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);
| ~~~~~~~~~~~~
&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;