]> The Tcpdump Group git mirrors - libpcap/commitdiff
usb-linux: fix calculation of on-the-wire length.
authorGuy Harris <[email protected]>
Mon, 15 Aug 2022 05:45:34 +0000 (22:45 -0700)
committerGuy Harris <[email protected]>
Sun, 28 Aug 2022 00:39:08 +0000 (17:39 -0700)
Ignore descriptors with a zero length; the only data that matters when
recalculating the on-the-wire length are the ones with data, as the goal
is to calculate the length of data that we would have gotten had neither
usbmon nor libpcap truncated the data, and if there's no data to
truncate....

(cherry picked from commit a879397a5890f48654b4e61ebbf1d4e69d1eb19a)

pcap-usb-linux-common.c

index 6bd044c953350b69b2365a75011993ec9dcd44b4..fb4a8c19be75c930293f2322215f41dc79362c9c 100644 (file)
@@ -81,9 +81,11 @@ fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth, const u_char *bp)
                    desc++, bytes_left -= sizeof (usb_isodesc)) {
                        u_int desc_end;
 
-                       desc_end = descs[desc].offset + descs[desc].len;
-                       if (desc_end > pre_truncation_data_len)
-                               pre_truncation_data_len = desc_end;
+                       if (descs[desc].len != 0) {
+                               desc_end = descs[desc].offset + descs[desc].len;
+                               if (desc_end > pre_truncation_data_len)
+                                       pre_truncation_data_len = desc_end;
+                       }
                }
 
                /*