From bbef61803291ef306dc86afe2249551c3aae593c Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Thu, 13 Oct 2022 16:01:02 +0900 Subject: [PATCH] [KBSWITCH][IMM32][USER32] Consider keyboard layout corner cases Considering invalid Keyboard Layout registry entries. CORE-11700 --- base/applications/kbswitch/kbswitch.c | 2 +- dll/win32/imm32/utils.c | 6 +++--- win32ss/user/user32/windows/input.c | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index 356209d0c6a..6e301ee5207 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -341,7 +341,7 @@ BuildLeftPopupMenu(VOID) } if (!GetLayoutName(szLayoutNum, szName, ARRAYSIZE(szName))) - break; + continue; AppendMenu(hMenu, MF_STRING, _ttoi(szLayoutNum), szName); } diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c index 90fa7d6c1d1..cde837ece0e 100644 --- a/dll/win32/imm32/utils.c +++ b/dll/win32/imm32/utils.c @@ -898,7 +898,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts) lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key */ if (lError != ERROR_SUCCESS) - break; + continue; /* Load the "Ime File" value */ szImeFileName[0] = 0; @@ -910,12 +910,12 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts) /* We don't allow the invalid "IME File" values for security reason */ if (!szImeFileName[0] || wcscspn(szImeFileName, L":\\/") != wcslen(szImeFileName)) - break; + continue; Imm32StrToUInt(szImeKey, &Value, 16); hKL = (HKL)(DWORD_PTR)Value; if (!IS_IME_HKL(hKL)) - break; + continue; /* Store the IME key and the IME filename */ pLayouts[nCount].hKL = hKL; diff --git a/win32ss/user/user32/windows/input.c b/win32ss/user/user32/windows/input.c index 092a92efefc..a15e9b57810 100644 --- a/win32ss/user/user32/windows/input.c +++ b/win32ss/user/user32/windows/input.c @@ -796,6 +796,7 @@ IntLoadKeyboardLayout( { bIsIME = FALSE; wHigh = 0; + ERR("0x%X\n", dwKLID); } else { @@ -810,6 +811,7 @@ IntLoadKeyboardLayout( { bIsIME = FALSE; wHigh = 0; + ERR("'%s'\n", debugstr_w(szPath)); } } }