Akihiro Sagawa : advapi32: RegLoadMUIString doesn' t accept a string without '@' prefix.

Alexandre Julliard julliard at winehq.org
Mon May 27 14:50:20 CDT 2019


Module: wine
Branch: master
Commit: 1ed4c150a2d109c2795e280898fdcd3f69d4ff9f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1ed4c150a2d109c2795e280898fdcd3f69d4ff9f

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Sun May 26 21:15:03 2019 +0900

advapi32: RegLoadMUIString doesn't accept a string without '@' prefix.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/advapi32/registry.c       | 16 ++++++++--------
 dlls/advapi32/tests/registry.c |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index f889d3b..c3c2950 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -3247,6 +3247,12 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
     result = RegQueryValueExW(hKey, pwszValue, NULL, &dwValueType, (LPBYTE)pwszTempBuffer, &cbData);
     if (result != ERROR_SUCCESS) goto cleanup;
 
+    /* '@' is the prefix for resource based string entries. */
+    if (*pwszTempBuffer != '@') {
+        result = ERROR_INVALID_DATA;
+        goto cleanup;
+    }
+
     /* Expand environment variables, if appropriate, or copy the original string over. */
     if (dwValueType == REG_EXPAND_SZ) {
         cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR);
@@ -3262,14 +3268,8 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
         memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData);
     }
 
-    /* If the value references a resource based string, parse the value and load the string.
-     * Else just copy over the original value. */
-    result = ERROR_SUCCESS;
-    if (*pwszExpandedBuffer != '@') { /* '@' is the prefix for resource based string entries. */
-        lstrcpynW(pwszBuffer, pwszExpandedBuffer, cbBuffer / sizeof(WCHAR));
-        if (pcbData)
-            *pcbData = (strlenW(pwszExpandedBuffer) + 1) * sizeof(WCHAR);
-    } else {
+    /* Parse the value and load the string. */
+    {
         WCHAR *pComma = strrchrW(pwszExpandedBuffer, ','), *pNewBuffer;
         const WCHAR backslashW[] = {'\\',0};
         UINT uiStringId;
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 911186f..a1b9dd1 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -3857,14 +3857,14 @@ static void test_RegLoadMUIString(void)
         BOOL todo;
     } test_case[] = {
         /* 0 */
-        { "",                  REG_SZ,        FALSE, ERROR_INVALID_DATA, 0, TRUE },
-        { "not a MUI string",  REG_SZ,        FALSE, ERROR_INVALID_DATA, 0, TRUE },
+        { "",                  REG_SZ,        FALSE, ERROR_INVALID_DATA },
+        { "not a MUI string",  REG_SZ,        FALSE, ERROR_INVALID_DATA },
         { "@unknown.dll",      REG_SZ,        TRUE,  ERROR_INVALID_DATA, 0, TRUE },
         { "@unknown.dll,-10",  REG_SZ,        TRUE,  ERROR_FILE_NOT_FOUND },
         /*  4 */
         { with_env_var,        REG_SZ,        FALSE, ERROR_SUCCESS, 0, TRUE },
         { with_env_var,        REG_EXPAND_SZ, FALSE, ERROR_SUCCESS },
-        { "%WineMuiTest1%",    REG_EXPAND_SZ, TRUE,  ERROR_INVALID_DATA, 0, TRUE },
+        { "%WineMuiTest1%",    REG_EXPAND_SZ, TRUE,  ERROR_INVALID_DATA },
         { "@%WineMuiTest2%",   REG_EXPAND_SZ, TRUE,  ERROR_SUCCESS },
         /*  8 */
         { "@%WineMuiExe%,a",   REG_SZ,        FALSE, ERROR_INVALID_DATA, 0, TRUE },




More information about the wine-cvs mailing list