aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-08-14 22:45:34 -0700
committerGuy Harris <gharris@sonic.net>2022-08-14 22:45:34 -0700
commita879397a5890f48654b4e61ebbf1d4e69d1eb19a (patch)
treec5cabfe83f42cf0b71323a1c19049c614034bc38
parent23f2c6d1f95054edee87b4431a7cb54d1c48a876 (diff)
usb-linux: fix calculation of on-the-wire length.
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....
-rw-r--r--pcap-usb-linux-common.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pcap-usb-linux-common.c b/pcap-usb-linux-common.c
index 6bd044c9..fb4a8c19 100644
--- a/pcap-usb-linux-common.c
+++ b/pcap-usb-linux-common.c
@@ -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;
+ }
}
/*