Author: ekohl
Date: Sat Dec  4 08:54:16 2010
New Revision: 49945

URL: http://svn.reactos.org/svn/reactos?rev=49945&view=rev
Log:
[NPFS]
Read and write IRPs must fail if the caller is not a pipe but a directory or a 
device.

Modified:
    trunk/reactos/drivers/filesystems/npfs/rw.c

Modified: trunk/reactos/drivers/filesystems/npfs/rw.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/rw.c?rev=49945&r1=49944&r2=49945&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] Sat Dec  4 
08:54:16 2010
@@ -307,6 +307,20 @@
 
     DPRINT("NpfsRead(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
 
+    FileObject = IoGetCurrentIrpStackLocation(Irp)->FileObject;
+    DPRINT("FileObject %p\n", FileObject);
+    DPRINT("Pipe name %wZ\n", &FileObject->FileName);
+    Ccb = FileObject->FsContext2;
+
+    /* Fail, if the CCB is not a pipe CCB */
+    if (Ccb->Type != CCB_PIPE)
+    {
+        DPRINT("Not a pipe!\n");
+        Status = STATUS_INVALID_PARAMETER;
+        Irp->IoStatus.Information = 0;
+        goto done;
+    }
+
     if (Irp->MdlAddress == NULL)
     {
         DPRINT("Irp->MdlAddress == NULL\n");
@@ -315,10 +329,6 @@
         goto done;
     }
 
-    FileObject = IoGetCurrentIrpStackLocation(Irp)->FileObject;
-    DPRINT("FileObject %p\n", FileObject);
-    DPRINT("Pipe name %wZ\n", &FileObject->FileName);
-    Ccb = FileObject->FsContext2;
     Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext;
 
     if ((Ccb->OtherSide) && (Ccb->OtherSide->PipeState == 
FILE_PIPE_DISCONNECTED_STATE) && (Ccb->PipeState == 
FILE_PIPE_DISCONNECTED_STATE))
@@ -736,7 +746,7 @@
     NTSTATUS Status = STATUS_SUCCESS;
     ULONG Length;
     ULONG Offset;
-    ULONG Information;
+    ULONG Information = 0;
     ULONG CopyLength;
     ULONG TempLength;
 
@@ -748,12 +758,21 @@
     DPRINT("Pipe name %wZ\n", &FileObject->FileName);
 
     Ccb = FileObject->FsContext2;
+
+    /* Fail, if the CCB is not a pipe CCB */
+    if (Ccb->Type != CCB_PIPE)
+    {
+        DPRINT("Not a pipe!\n");
+        Status = STATUS_INVALID_PARAMETER;
+        Length = 0;
+        goto done;
+    }
+
     ReaderCcb = Ccb->OtherSide;
     Fcb = Ccb->Fcb;
 
     Length = IoStack->Parameters.Write.Length;
     Offset = IoStack->Parameters.Write.ByteOffset.u.LowPart;
-    Information = 0;
 
     if (Irp->MdlAddress == NULL)
     {


Reply via email to