[UMPNPMGR] GenerateDeviceID must fail, if pszDeviceID contains backslashes
authorEric Kohl <eric.kohl@reactos.org>
Tue, 19 Apr 2022 21:14:23 +0000 (23:14 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 19 Apr 2022 21:14:23 +0000 (23:14 +0200)
base/services/umpnpmgr/rpcserver.c

index 2546197..1d933e6 100644 (file)
@@ -3004,11 +3004,20 @@ GenerateDeviceID(
     _In_ PNP_RPC_STRING_LEN ulLength)
 {
     WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
+    PWCHAR ptr;
     HKEY hKey;
     DWORD dwInstanceNumber;
     DWORD dwError = ERROR_SUCCESS;
     CONFIGRET ret = CR_SUCCESS;
 
+    /* Fail, if the device name contains backslashes */
+    ptr = pszDeviceID;
+    while (*ptr != UNICODE_NULL)
+    {
+        if (*ptr == L'\\')
+            return CR_INVALID_DEVICE_ID;
+    }
+
     /* Generated ID is: Root\<Device ID>\<Instance number> */
     dwInstanceNumber = 0;
     while (dwError == ERROR_SUCCESS)