[USER32] Don't allow invalid 'IME File' values

Improve security. CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-09-16 17:59:48 +09:00
parent 787bbf0693
commit b4575eccd7

View File

@ -801,7 +801,11 @@ IntLoadKeyboardLayout(
{ {
WCHAR szPath[MAX_PATH]; WCHAR szPath[MAX_PATH];
GetSystemLibraryPath(szPath, _countof(szPath), szImeFileName); GetSystemLibraryPath(szPath, _countof(szPath), szImeFileName);
if (GetFileAttributesW(szPath) == INVALID_FILE_ATTRIBUTES) /* Does not exist? */
/* We don't allow the invalid "IME File" values for security reason */
if (dwType != REG_SZ || szImeFileName[0] == 0 ||
wcsspn(szImeFileName, L":\\/") != wcslen(szImeFileName) ||
GetFileAttributesW(szPath) == INVALID_FILE_ATTRIBUTES) /* Does not exist? */
{ {
bIsIME = FALSE; bIsIME = FALSE;
wHigh = 0; wHigh = 0;