https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2505bd3a4312f42a413cfc2e06b2227f92183126

commit 2505bd3a4312f42a413cfc2e06b2227f92183126
Author:     Serge Gautherie <[email protected]>
AuthorDate: Thu Feb 13 03:25:42 2020 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sun Apr 26 14:16:59 2020 +0200

    [ROSPERF] PrintOSVersion(): Fix RegQueryValueExW() use
---
 .../applications/sysutils/utils/rosperf/rosperf.c       | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/rosapps/applications/sysutils/utils/rosperf/rosperf.c 
b/modules/rosapps/applications/sysutils/utils/rosperf/rosperf.c
index 8f9acf4c7be..85fa34e1cb3 100644
--- a/modules/rosapps/applications/sysutils/utils/rosperf/rosperf.c
+++ b/modules/rosapps/applications/sysutils/utils/rosperf/rosperf.c
@@ -290,12 +290,11 @@ ProcessTest(PTEST Test, PPERF_INFO PerfInfo)
 static void
 PrintOSVersion(void)
 {
-#define BUFSIZE 160
   OSVERSIONINFOEXW VersionInfo;
   BOOL OsVersionInfoEx;
   HKEY hKey;
-  WCHAR ProductType[BUFSIZE];
-  DWORD BufLen;
+  WCHAR ProductType[9] = { L'\0' };
+  DWORD BufLen, dwType;
   LONG Ret;
   unsigned RosVersionLen;
   LPWSTR RosVersion;
@@ -423,8 +422,6 @@ PrintOSVersion(void)
           }
         else  /* Test for specific product on Windows NT 4.0 SP5 and earlier */
           {
-            BufLen = BUFSIZE;
-
             Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                 
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
                                 0, KEY_QUERY_VALUE, &hKey);
@@ -433,15 +430,17 @@ PrintOSVersion(void)
                 return;
               }
 
-            Ret = RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+            BufLen = sizeof(ProductType);
+            Ret = RegQueryValueExW(hKey, L"ProductType", NULL, &dwType,
                                    (LPBYTE) ProductType, &BufLen);
-            if (ERROR_SUCCESS != Ret || BUFSIZE < BufLen)
+
+            RegCloseKey(hKey);
+
+            if (Ret != ERROR_SUCCESS || dwType != REG_SZ)
               {
                 return;
               }
 
-            RegCloseKey(hKey);
-
             if (0 == lstrcmpiW(L"WINNT", ProductType))
               {
                 wprintf(L"Workstation ");

Reply via email to