Skip to content

Commit

Permalink
Do not subtract the SLL[2]_HDR_LEN if the location is negative.
Browse files Browse the repository at this point in the history
This fixes the offset issue I mention in
the-tcpdump-group/tcpdump#480 (comment)
  • Loading branch information
fenner committed Apr 27, 2019
1 parent 3e21907 commit 926dacf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pcap-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -7427,7 +7427,7 @@ fix_offset(pcap_t *handle, struct bpf_insn *p)
/*
* What's the offset?
*/
if (p->k >= SLL2_HDR_LEN) {
if ((bpf_int32)p->k >= SLL2_HDR_LEN) {
/*
* It's within the link-layer payload; that starts
* at an offset of 0, as far as the kernel packet
Expand Down Expand Up @@ -7459,7 +7459,7 @@ fix_offset(pcap_t *handle, struct bpf_insn *p)
/*
* What's the offset?
*/
if (p->k >= SLL_HDR_LEN) {
if ((bpf_int32)p->k >= SLL_HDR_LEN) {
/*
* It's within the link-layer payload; that starts
* at an offset of 0, as far as the kernel packet
Expand Down

0 comments on commit 926dacf

Please sign in to comment.