[NPFS]
authorThomas Faber <thomas.faber@reactos.org>
Thu, 16 Oct 2014 16:40:13 +0000 (16:40 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 16 Oct 2014 16:40:13 +0000 (16:40 +0000)
- Don't call RtlEqualUnicodeString (paged code) while holding a spin lock. Powered by Driver Verifier.

svn path=/trunk/; revision=64762

reactos/drivers/filesystems/npfs/waitsup.c

index 42e15e8..31c9808 100644 (file)
@@ -99,6 +99,22 @@ NpInitializeWaitQueue(IN PNP_WAIT_QUEUE WaitQueue)
     KeInitializeSpinLock(&WaitQueue->WaitLock);
 }
 
+static
+BOOLEAN
+NpEqualUnicodeString(IN PCUNICODE_STRING String1,
+                     IN PCUNICODE_STRING String2)
+{
+    SIZE_T EqualLength;
+
+    if (String1->Length != String2->Length)
+        return FALSE;
+
+    EqualLength = RtlCompareMemory(String1->Buffer,
+                                   String2->Buffer,
+                                   String1->Length);
+    return EqualLength == String1->Length;
+}
+
 NTSTATUS
 NTAPI
 NpCancelWaiter(IN PNP_WAIT_QUEUE WaitQueue,
@@ -156,7 +172,8 @@ NpCancelWaiter(IN PNP_WAIT_QUEUE WaitQueue,
             PipeName.MaximumLength = PipeName.Length;
         }
 
-        if (RtlEqualUnicodeString(&WaitName, &PipeName, FALSE))
+        /* Can't use RtlEqualUnicodeString with a spinlock held */
+        if (NpEqualUnicodeString(&WaitName, &PipeName))
         {
             /* Found a matching wait. Cancel it */
             RemoveEntryList(&WaitIrp->Tail.Overlay.ListEntry);