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:
Toke Høiland-Jørgensen
2021-03-09 23:09:13 +01:00
parent 97fdefa90d
commit a10dc23e4a

View File

@ -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 */