From 75ccd2283b084efe7723875adee02e570e4ba481 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 4 Jan 2023 17:16:27 +0300 Subject: [PATCH] public: fix Q_memmem counting haystack size incorrectly --- public/crtlib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/crtlib.c b/public/crtlib.c index b1d7ee5c..3561a1be 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -382,8 +382,11 @@ const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *need if( !memcmp( i, needle, needlelen )) return i; + // skip one byte + i++; + haystacklen -= i - haystack; - haystack = i + 1; + haystack = i; } return NULL;