https://git.reactos.org/?p=reactos.git;a=commitdiff;h=10acb335fa670e2b3865d0c2a9b97d8f8c6df7cc

commit 10acb335fa670e2b3865d0c2a9b97d8f8c6df7cc
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Wed Oct 19 17:01:20 2022 +0900
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Wed Oct 19 17:03:54 2022 +0900

    [USER32] Improve CliGetImeHotKeysFromRegistry
    
    CORE-11700
---
 win32ss/user/user32/windows/input.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/win32ss/user/user32/windows/input.c 
b/win32ss/user/user32/windows/input.c
index 220dd4c3cfe..aac99382113 100644
--- a/win32ss/user/user32/windows/input.c
+++ b/win32ss/user/user32/windows/input.c
@@ -345,19 +345,19 @@ BOOL FASTCALL CliGetImeHotKeysFromRegistry(VOID)
     error = RegOpenKeyExW(HKEY_CURRENT_USER,
                           L"Control Panel\\Input Method\\Hot Keys",
                           0,
-                          KEY_ALL_ACCESS,
+                          KEY_READ,
                           &hKey);
     if (error != ERROR_SUCCESS)
         return ret;
 
-    for (dwIndex = 0; ; ++dwIndex)
+    for (dwIndex = 0; dwIndex < 1000; ++dwIndex)
     {
         cchKeyName = _countof(szKeyName);
         error = RegEnumKeyExW(hKey, dwIndex, szKeyName, &cchKeyName, NULL, 
NULL, NULL, NULL);
-        if (error == ERROR_NO_MORE_ITEMS || error != ERROR_SUCCESS)
+        if (error != ERROR_SUCCESS)
             break;
 
-        szKeyName[_countof(szKeyName) - 1] = 0;
+        szKeyName[_countof(szKeyName) - 1] = 0; /* Avoid stack overrun */
 
         if (CliSetSingleHotKey(szKeyName, hKey))
             ret = TRUE;

Reply via email to