Skip to content

Commit

Permalink
usb-linux: fix calculation of on-the-wire length.
Browse files Browse the repository at this point in the history
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....
  • Loading branch information
guyharris committed Aug 15, 2022
1 parent 23f2c6d commit a879397
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pcap-usb-linux-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/*
Expand Down

0 comments on commit a879397

Please sign in to comment.