From dd324f5be09fa151c2ea6637c4b3ed64d691a86e Mon Sep 17 00:00:00 2001 From: Charles Cottrill Date: Wed, 29 Nov 2023 18:08:05 -0500 Subject: [PATCH 1/5] Handle IPv6 fragment extension header only return NULL when reached end of packet (no data) --- src/common/get.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/common/get.c b/src/common/get.c index 2d911160..c9ab3f6b 100644 --- a/src/common/get.c +++ b/src/common/get.c @@ -593,9 +593,25 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr, const u_char *end_ptr) break; /* - * Can't handle. Unparsable IPv6 fragment/encrypted data + * handle (unparsable) IPv6 fragment data */ case TCPR_IPV6_NH_FRAGMENT: + // next points to l4 data + dbgx(3, "Go deeper due to fragment extension header 0x%02X", proto); + exthdr = get_ipv6_next(next, end_ptr); + if (exthdr > end_ptr) { + next = NULL; + done = true; + break; + } + proto = exthdr->ip_nh; + next = exthdr; + // done = true; + break; + + /* + * Can't handle. Unparsable IPv6 encrypted data + */ case TCPR_IPV6_NH_ESP: next = NULL; done = true; From 58f935e64344274499bba1ff86317e50dc25a8bc Mon Sep 17 00:00:00 2001 From: Charles Cottrill Date: Tue, 12 Dec 2023 14:10:23 -0500 Subject: [PATCH 2/5] check for NULL ptr --- src/common/get.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/get.c b/src/common/get.c index c9ab3f6b..2437cfa5 100644 --- a/src/common/get.c +++ b/src/common/get.c @@ -599,7 +599,7 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr, const u_char *end_ptr) // next points to l4 data dbgx(3, "Go deeper due to fragment extension header 0x%02X", proto); exthdr = get_ipv6_next(next, end_ptr); - if (exthdr > end_ptr) { + if ((NULL == exthdr) || (exthdr > end_ptr)) { next = NULL; done = true; break; From c4ee66de6313d9d9169b1e2f1ca44b9b9c925dad Mon Sep 17 00:00:00 2001 From: Charles Cottrill Date: Thu, 14 Dec 2023 16:58:22 -0500 Subject: [PATCH 3/5] resolve warning --- src/common/get.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/get.c b/src/common/get.c index 2437cfa5..b3bf3661 100644 --- a/src/common/get.c +++ b/src/common/get.c @@ -599,7 +599,7 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr, const u_char *end_ptr) // next points to l4 data dbgx(3, "Go deeper due to fragment extension header 0x%02X", proto); exthdr = get_ipv6_next(next, end_ptr); - if ((NULL == exthdr) || (exthdr > end_ptr)) { + if ((NULL == exthdr) || ((u_char *)exthdr > end_ptr)) { next = NULL; done = true; break; From a591bf795055c4f8ef73f26d764cfb94435c9e49 Mon Sep 17 00:00:00 2001 From: Charles Cottrill Date: Fri, 15 Dec 2023 20:51:22 -0500 Subject: [PATCH 4/5] revise comparison to match rest of code --- src/common/get.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/get.c b/src/common/get.c index b3bf3661..95ca15b8 100644 --- a/src/common/get.c +++ b/src/common/get.c @@ -599,7 +599,7 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr, const u_char *end_ptr) // next points to l4 data dbgx(3, "Go deeper due to fragment extension header 0x%02X", proto); exthdr = get_ipv6_next(next, end_ptr); - if ((NULL == exthdr) || ((u_char *)exthdr > end_ptr)) { + if ((exthdr == NULL) || ((u_char *)exthdr > end_ptr)) { next = NULL; done = true; break; From 6b5131d654664b0c4b35a0ead50b29983a020b31 Mon Sep 17 00:00:00 2001 From: Fred Klassen Date: Tue, 26 Dec 2023 13:09:26 -0800 Subject: [PATCH 5/5] Bug #837 - update CHANGELOG and CREDIT downstream PR #832 from Chuck Cottrill --- docs/CHANGELOG | 1 + docs/CREDIT | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 331e4de3..99e0d31b 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -1,4 +1,5 @@ 09/03/2023 Version 4.5.0-beta1 + - handle IPv6 fragment extension header (#832 #837) - low PPS values run at full speed after several days (#779) - create DLT_LINUX_SLL2 plugin (#727) diff --git a/docs/CREDIT b/docs/CREDIT index 38e200f6..af043fde 100644 --- a/docs/CREDIT +++ b/docs/CREDIT @@ -116,3 +116,5 @@ David Guti Bastian Triller - Linux SLL2 + +Chuck Cottrill \ No newline at end of file