mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
parsing_helpers: Fix sizeof checks
As reported in the xdp-tutorial (where this code is from), there were a couple of sizeof checks in parsing_helpers.h that was using the pointer size instead of the size of the struct being pointed to. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This commit is contained in:
@ -202,7 +202,7 @@ static __always_inline int parse_iphdr(struct hdr_cursor *nh,
|
||||
|
||||
hdrsize = iph->ihl * 4;
|
||||
/* Sanity check packet field is valid */
|
||||
if(hdrsize < sizeof(iph))
|
||||
if(hdrsize < sizeof(*iph))
|
||||
return -1;
|
||||
|
||||
/* Variable-length IPv4 header, need to use byte-based arithmetic */
|
||||
@ -298,7 +298,7 @@ static __always_inline int parse_tcphdr(struct hdr_cursor *nh,
|
||||
|
||||
len = h->doff * 4;
|
||||
/* Sanity check packet field is valid */
|
||||
if(len < sizeof(h))
|
||||
if(len < sizeof(*h))
|
||||
return -1;
|
||||
|
||||
/* Variable-length TCP header, need to use byte-based arithmetic */
|
||||
|
Reference in New Issue
Block a user