diff options
author | Guy Harris <gharris@sonic.net> | 2022-07-12 16:12:40 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-07-12 16:12:40 -0700 |
commit | e2c0fd75e48a3cbf1bf48b8afe28fff50d8e0877 (patch) | |
tree | 61623b5d798667c05ece96d1d6d50fe62a086ba6 /pcap-usb-linux-common.c | |
parent | 7610a61d72c818067a1e51f150b81ee7d489a577 (diff) |
Linux USB: check the captured length early in the fixup process.
In fixup_pcap_pkthdr(), check th capture length to make sure it has a
full header before we start looking at fields in the header.
The other place that calls fix_linux_usb_mmapped_length() already
ensures that we have at least a full USB metadata header; this change
means that both places that call it do, so we can remove the check from
fix_linux_usb_mmapped_length() itself.
Diffstat (limited to 'pcap-usb-linux-common.c')
-rw-r--r-- | pcap-usb-linux-common.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/pcap-usb-linux-common.c b/pcap-usb-linux-common.c index d5d9e538..6bd044c9 100644 --- a/pcap-usb-linux-common.c +++ b/pcap-usb-linux-common.c @@ -41,13 +41,11 @@ fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth, const u_char *bp) const pcap_usb_header_mmapped *hdr; u_int bytes_left; + /* + * All callers of this routine must ensure that pkth->caplen is + * >= sizeof (pcap_usb_header_mmapped). + */ bytes_left = pkth->caplen; - if (bytes_left < sizeof (pcap_usb_header_mmapped)) { - /* - * We don't have the full metadata header, so give up. - */ - return; - } bytes_left -= sizeof (pcap_usb_header_mmapped); hdr = (const pcap_usb_header_mmapped *) bp; |