Skip to content

Commit d419031

Browse files
committed
common/parsing_helpers.h: Fix sizeof checks to use pointer target
Marcus noticed that there was a sizeof() check in parsing_helpers that was using the size of the pointer, not of the struct being pointed to. Turns out there were two of these, so let's fix both. Fixes #199. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
1 parent 2ba3740 commit d419031

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

common/parsing_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static __always_inline int parse_iphdr(struct hdr_cursor *nh,
160160

161161
hdrsize = iph->ihl * 4;
162162
/* Sanity check packet field is valid */
163-
if(hdrsize < sizeof(iph))
163+
if(hdrsize < sizeof(*iph))
164164
return -1;
165165

166166
/* Variable-length IPv4 header, need to use byte-based arithmetic */
@@ -256,7 +256,7 @@ static __always_inline int parse_tcphdr(struct hdr_cursor *nh,
256256

257257
len = h->doff * 4;
258258
/* Sanity check packet field is valid */
259-
if(len < sizeof(h))
259+
if(len < sizeof(*h))
260260
return -1;
261261

262262
/* Variable-length TCP header, need to use byte-based arithmetic */

0 commit comments

Comments
 (0)