From 9d71c0f9341711c5b0094bf95d087251689112a4 Mon Sep 17 00:00:00 2001 From: Nathaniel Ferguson Date: Sun, 3 May 2020 03:12:37 -0400 Subject: proto_ipv4: Make netsniff detect and properly handle some malformed packets Entails the potential integer underflow of a signed integer. Signed-off-by: Nathaniel Ferguson Signed-off-by: Tobias Klauser --- proto_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto_ipv4.c b/proto_ipv4.c index e2d22d8..e522a90 100644 --- a/proto_ipv4.c +++ b/proto_ipv4.c @@ -154,7 +154,7 @@ static void ipv4(struct pkt_buff *pkt) * check and handle that */ opt_len = *(++opt); - if (opt_len > opts_len) { + if (opt_len < 2 || opt_len > opts_len) { tprintf(", Len (%zd, invalid) ]\n", opt_len); goto out; } else -- cgit v1.2.3-54-g00ecf