From f34d51dddc3f01d5368ae1cab5f7f8dc73bc9b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 30 Mar 2025 16:38:54 +0800 Subject: [PATCH] Terminal (Windows): fix file version detection --- src/detection/terminalshell/terminalshell.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 92bd7294e..f4c8a076e 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -22,9 +22,11 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, FFstrbuf* version) { - wchar_t exePathW[PATH_MAX]; + wchar_t exePathW[PATH_MAX + 1]; int len = MultiByteToWideChar(CP_UTF8, 0, exePath->chars, (int)exePath->length, exePathW, ARRAY_SIZE(exePathW)); if (len <= 0) return false; + assert(len < (int) ARRAY_SIZE(exePathW)); + exePathW[len] = L'\0'; return ffGetFileVersion(exePathW, stringName, version); }