]> The Tcpdump Group git mirrors - libpcap/commitdiff
usb-linux: Use sizeof() rather than a number
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 15 Aug 2020 07:39:51 +0000 (09:39 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 15 Aug 2020 07:43:03 +0000 (09:43 +0200)
pcap-usb-linux.c

index 436a8452b825c564537fffebd2c50b6f6faf40b5..9e7e8404fd4896be689bd23a7d4dd1951a4df970 100644 (file)
@@ -902,7 +902,7 @@ usb_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_cha
                char string_truncated[181];
 
                strncpy(string_truncated, string, sizeof(string_truncated));
-               string_truncated[180] = 0;
+               string_truncated[sizeof(string_truncated) - 1] = 0;
                snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
                         "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)",
                         string_truncated, ret);