From 6a317366d7aef7643d4559a522fda0e4ea798969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 19 Oct 2025 09:41:01 +0800 Subject: [PATCH] Shell: fix fish version detection when `LC_ALL` is set Fixes #2014 --- src/detection/terminalshell/terminalshell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 48476b63a..032f27cf4 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -6,6 +6,7 @@ #include "util/binary.h" #include +#include #ifdef __FreeBSD__ #include #ifndef _PATH_LOCALBASE @@ -85,8 +86,10 @@ static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) if(!getExeVersionRaw(exe, version)) return false; - //fish, version 4.0.2-1 (Built by MSYS2 project) - ffStrbufSubstrAfterFirstS(version, "version "); + //fish, version 4.0.2-1 (Built by MSYS2 project) // version can be localized if LC_ALL is set + if (version->length < strlen("fish, v")) return false; + uint32_t index = ffStrbufNextIndexC(version, strlen("fish, "), ' '); + ffStrbufSubstrAfter(version, index); ffStrbufSubstrBeforeFirstC(version, ' '); return true; }