Skip to content

Commit

Permalink
Merge pull request #820 from fenner/preserve-negative-offsets
Browse files Browse the repository at this point in the history
Do not subtract the SLL[2]_HDR_LEN if the location is negative.
  • Loading branch information
guyharris authored Sep 30, 2019
2 parents 14db34d + eebbdd4 commit c73dbad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pcap-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -7496,6 +7496,14 @@ fix_program(pcap_t *handle, struct sock_fprog *fcode, int is_mmapped)
static int
fix_offset(pcap_t *handle, struct bpf_insn *p)
{
/*
* Existing references to auxiliary data shouldn't be adjusted.
*
* Note that SKF_AD_OFF is negative, but p->k is unsigned, so
* we use >= and cast SKF_AD_OFF to unsigned.
*/
if (p->k >= (bpf_u_int32)SKF_AD_OFF)
return 0;
if (handle->linktype == DLT_LINUX_SLL2) {
/*
* What's the offset?
Expand Down

0 comments on commit c73dbad

Please sign in to comment.