From fcf4aca3b76c5160335a4f35add04c4141cbb3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 4 Aug 2026 21:14:48 +0800 Subject: [PATCH] Shell: fixes a potencial out-of-bound read --- src/detection/terminalshell/terminalshell.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 2d531f971..fa323aa9e 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -90,11 +90,11 @@ static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) { return false; } uint32_t index = ffStrbufFirstIndexC(version, ' '); // skip "fish," - while (!ffCharIsDigit(version->chars[index + 1])) { + while (index + 1 < version->length && !ffCharIsDigit(version->chars[index + 1])) { index = ffStrbufNextIndexC(version, index + 1, ' '); // skip "version" - if (index == version->length) { - return false; - } + } + if (index + 1 >= version->length) { + return false; } ffStrbufSubstrAfter(version, index);