From fc747b0ebadd281ea07f34935c872aef0554842f Mon Sep 17 00:00:00 2001 From: chrg6 Date: Mon, 9 Nov 2026 05:57:22 -0500 Subject: [PATCH] Check the length of LOCALAPPDATA in the setup before appending to it. Co-Authored-By: Claude Opus 5.5 --- launcher/native/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/launcher/native/setup.c b/launcher/native/setup.c index dac4989b..f2f13ce4 100644 --- a/launcher/native/setup.c +++ b/launcher/native/setup.c @@ -373,7 +373,9 @@ int WINAPI wWinMain(HINSTANCE inst, HINSTANCE prev, PWSTR cmdline, int show) if (!S.dest[0]) { wchar_t base[PATHN]; if (!known_folder(&FOLDERID_UserProgramFiles, base, PATHN)) { - if (!GetEnvironmentVariableW(L"LOCALAPPDATA", base, PATHN)) return 1; + // 0 when unset; PATHN or more when it does not fit (base is then left unwritten); room for \Programs + DWORD got = GetEnvironmentVariableW(L"LOCALAPPDATA", base, PATHN); + if (!got || got >= PATHN - 16) return 1; wcscat(base, L"\\Programs"); } swprintf(S.dest, PATHN, L"%ls\\%ls", base, APP_NAME);