[UMPNPMGR] Add checks to PNP_GetRelatedDeviceInstance
authorEric Kohl <eric.kohl@reactos.org>
Sun, 17 Apr 2022 11:52:59 +0000 (13:52 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 17 Apr 2022 11:52:59 +0000 (13:52 +0200)
PNP_GetRelatedDeviceInstance must fail if we try to retrieve the parent or a sibling of the root device.

base/services/umpnpmgr/rpcserver.c

index 34bdf84..470a9b6 100644 (file)
@@ -781,6 +781,14 @@ PNP_GetRelatedDeviceInstance(
     if (!IsValidDeviceInstanceID(pDeviceID))
         return CR_INVALID_DEVINST;
 
+    /* The root device does not have a parent device or sibling devices */
+    if ((ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE) ||
+        (ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE))
+    {
+        if (IsRootDeviceInstanceID(pDeviceID))
+            return CR_NO_SUCH_DEVINST;
+    }
+
     RtlInitUnicodeString(&PlugPlayData.TargetDeviceInstance,
                          pDeviceID);