From 93175aea1de04f4741979e6af02262bf8b4fa1ff Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 25 Sep 2026 10:58:27 +0800 Subject: [PATCH] TerminalShell: clears version buffer if detection failed --- src/detection/terminalshell/terminalshell_linux.c | 8 ++++++-- src/detection/terminalshell/terminalshell_windows.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index b6a4d71bc..0b4ac8b50 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -429,7 +429,9 @@ const FFShellResult* ffDetectShell() { if (result->processName.length > 0) { setShellInfoDetails(result); if (instance.config.general.detectVersion) { - fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, result->exeName, &result->version); + if (!fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, result->exeName, &result->version)) { + ffStrbufClear(&result->version); + } } } @@ -484,7 +486,9 @@ const FFTerminalResult* ffDetectTerminal() { if (result->processName.length > 0) { setTerminalInfoDetails(result); if (instance.config.general.detectVersion) { - fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version); + if (!fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version)) { + ffStrbufClear(&result->version); + } } } diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index d4b33c19f..462cd1371 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -354,7 +354,9 @@ const FFShellResult* ffDetectShell(void) { *ext = '\0'; } if (instance.config.general.detectVersion) { - fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, tmp, &result->version); + if (!fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, tmp, &result->version)) { + ffStrbufClear(&result->version); + } } } @@ -415,7 +417,9 @@ const FFTerminalResult* ffDetectTerminal(void) { if (result->processName.length > 0) { setTerminalInfoDetails(result); if (instance.config.general.detectVersion) { - fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version); + if (!fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version)) { + ffStrbufClear(&result->version); + } } }