From efd98caef1908a05a38201c666218171b5eed765 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Wed, 20 Oct 2021 10:06:56 +0800 Subject: [PATCH] cmd: Pass size in bytes to RegQueryValueExW(). Signed-off-by: Zhiyi Zhang Signed-off-by: Alexandre Julliard --- programs/cmd/builtins.c | 5 +++-- programs/cmd/wcmdmain.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index a55ce6e0244..d0a954d90fa 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -4763,7 +4763,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { WCHAR *newValue; LONG rc = ERROR_SUCCESS; WCHAR keyValue[MAXSTRING]; - DWORD valueLen = MAXSTRING; + DWORD valueLen; HKEY readKey; /* See if parameter includes '=' */ @@ -4803,7 +4803,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) { - valueLen = ARRAY_SIZE(keyValue); + valueLen = sizeof(keyValue); rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen); WCMD_output_asis(keyName); WCMD_output_asis(L"="); @@ -4836,6 +4836,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) { + valueLen = sizeof(keyValue); rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen); WCMD_output_asis(args); WCMD_output_asis(L"="); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 8c6ed1c057c..4ed1c96a9c2 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2700,7 +2700,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) size = sizeof(DWORD); RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size); } else if (type == REG_SZ) { - size = ARRAY_SIZE(strvalue); + size = sizeof(strvalue); RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size); value = wcstoul(strvalue, NULL, 10); } @@ -2719,7 +2719,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) size = sizeof(DWORD); RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size); } else if (type == REG_SZ) { - size = ARRAY_SIZE(strvalue); + size = sizeof(strvalue); RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size); value = wcstoul(strvalue, NULL, 10); }