https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0296fce00ee07ef9e3df2fe04f8b3f01343d35a7

commit 0296fce00ee07ef9e3df2fe04f8b3f01343d35a7
Author:     Eric Kohl <[email protected]>
AuthorDate: Tue Apr 19 23:14:23 2022 +0200
Commit:     Eric Kohl <[email protected]>
CommitDate: Tue Apr 19 23:14:23 2022 +0200

    [UMPNPMGR] GenerateDeviceID must fail, if pszDeviceID contains backslashes
---
 base/services/umpnpmgr/rpcserver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/base/services/umpnpmgr/rpcserver.c 
b/base/services/umpnpmgr/rpcserver.c
index 25461975ee0..1d933e6942b 100644
--- a/base/services/umpnpmgr/rpcserver.c
+++ b/base/services/umpnpmgr/rpcserver.c
@@ -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)

Reply via email to