From b259a8214404f13f5ffac5a74ddc50b78d585eaa Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Mon, 27 Nov 2023 21:22:22 +0400 Subject: [PATCH] Update goodbyedpi.c --- src/goodbyedpi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/goodbyedpi.c b/src/goodbyedpi.c index 451120b..1afc9e0 100644 --- a/src/goodbyedpi.c +++ b/src/goodbyedpi.c @@ -428,12 +428,14 @@ static inline void change_window_size(const PWINDIVERT_TCPHDR ppTcpHdr, unsigned /* HTTP method end without trailing space */ static PVOID find_http_method_end(const char *pkt, unsigned int http_frag, int *is_fragmented) { unsigned int i; + unsigned int pkt_length = strlen(pkt); for (i = 0; i<(sizeof(http_methods) / sizeof(*http_methods)); i++) { unsigned int method_length = strlen(http_methods[i]); if (memcmp(pkt, http_methods[i], method_length) == 0) { if (is_fragmented) *is_fragmented = 0; - return (char*)pkt + method_length - 1; + if (method_length - 1 <= pkt_length) + return (char*)pkt + method_length - 1; } /* Try to find HTTP method in a second part of fragmented packet */ if ((http_frag == 1 || http_frag == 2) && @@ -443,14 +445,16 @@ static PVOID find_http_method_end(const char *pkt, unsigned int http_frag, int * { if (is_fragmented) *is_fragmented = 1; - return (char*)pkt + method_length - http_frag - 1; + if (method_length - http_frag - 1 <= pkt_length) + return (char*)pkt + method_length - http_frag - 1; } } - return (char*)pkt; + return NULL; } + /** Fragment and send the packet. * * This function cuts off the end of the packet (step=0) or