shell32: Avoid stack corruption with long name in SHELL_TryAppPathW().

This commit is contained in:
Paul Gofman 2023-09-28 19:29:03 -06:00 committed by Alexandre Julliard
parent 94e3e2d115
commit f1c57f06d6

View file

@ -428,8 +428,14 @@ static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
BOOL found = FALSE;
if (env) *env = NULL;
lstrcpyW(buffer, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
lstrcatW(buffer, szName);
wcscpy(buffer, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
if (wcslen(buffer) + wcslen(szName) + 1 > ARRAY_SIZE(buffer))
{
WARN("Name is too big.\n");
return FALSE;
}
wcscat(buffer, szName);
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp);
if (res) goto end;