Skip to content

Commit a84cdb8

Browse files
committed
IP: Improve a length check
Also perform the check for the presumed TSO case. Print "header length". Update a test output accordingly.
1 parent 7ffc618 commit a84cdb8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

print-ip.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ ip_print(netdissect_options *ndo,
353353
/* we guess that it is a TSO send */
354354
len = length;
355355
presumed_tso = 1;
356-
} else
357-
ND_ICHECKMSG_U("total length", len, <, hlen);
356+
}
357+
if (len < hlen) {
358+
ND_PRINT("[total length %u < header length %u]", len, hlen);
359+
goto invalid;
360+
}
358361

359362
ND_TCHECK_SIZE(ip);
360363
/*
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1 2023-08-25 08:57:44.621711 IP [total length 19 < 20] (invalid)
1+
1 2023-08-25 08:57:44.621711 IP [total length 19 < header length 20] (invalid)

0 commit comments

Comments
 (0)