From 1ed4c150a2d109c2795e280898fdcd3f69d4ff9f Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Sun, 26 May 2019 21:15:03 +0900 Subject: [PATCH] advapi32: RegLoadMUIString doesn't accept a string without '@' prefix. Signed-off-by: Akihiro Sagawa Signed-off-by: Alexandre Julliard --- 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 f889d3b0e5e..c3c2950d3d4 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 911186f3719..a1b9dd1c399 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 },