diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 3adca984f..48e5e2c38 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -224,7 +224,6 @@ static void getShellVersionZsh(FFstrbuf* exe, FFstrbuf* version) "--version", NULL }); - ffStrbufTrimRight(version, '\n'); ffStrbufSubstrBeforeLastC(version, ' '); ffStrbufSubstrAfterFirstC(version, ' '); } diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index d6397c6dc..687969606 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -184,6 +184,9 @@ static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { + if(strbuf->length == 0) + return strbuf->length; + return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c); }