mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:42:57 +00:00
- Protect against reads from (and writes to) closed named pipes.
svn path=/trunk/; revision=9319
This commit is contained in:
parent
83d8ef34bb
commit
eb065653f6
2 changed files with 33 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.19 2004/05/05 18:30:16 navaraf Exp $
|
/* $Id: create.c,v 1.20 2004/05/07 12:13:13 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -473,6 +473,7 @@ NpfsClose(
|
||||||
if (Fcb->OtherSide)
|
if (Fcb->OtherSide)
|
||||||
{
|
{
|
||||||
Fcb->OtherSide->PipeState = FILE_PIPE_CLOSING_STATE;
|
Fcb->OtherSide->PipeState = FILE_PIPE_CLOSING_STATE;
|
||||||
|
Fcb->OtherSide->OtherSide = NULL;
|
||||||
/*
|
/*
|
||||||
* Signaling the write event. If is possible that an other
|
* Signaling the write event. If is possible that an other
|
||||||
* thread waits of an empty buffer.
|
* thread waits of an empty buffer.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rw.c,v 1.13 2004/05/05 18:30:16 navaraf Exp $
|
/* $Id: rw.c,v 1.14 2004/05/07 12:13:13 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#include <rosrtl/minmax.h>
|
#include <rosrtl/minmax.h>
|
||||||
#include "npfs.h"
|
#include "npfs.h"
|
||||||
|
|
||||||
#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
@ -99,15 +99,25 @@ NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
Status = STATUS_PIPE_BROKEN;
|
Status = STATUS_PIPE_BROKEN;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Wait for ReadEvent to become signaled */
|
/* Wait for ReadEvent to become signaled */
|
||||||
DPRINT("Waiting for readable data (%S)\n", Pipe->PipeName.Buffer);
|
DPRINT("Waiting for readable data (%S)\n", Pipe->PipeName.Buffer);
|
||||||
Status = KeWaitForSingleObject(&Fcb->Event,
|
Status = KeWaitForSingleObject(&Fcb->Event,
|
||||||
UserRequest,
|
UserRequest,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status);
|
DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status);
|
||||||
KeAcquireSpinLock(&ReadFcb->DataListLock, &OldIrql);
|
/*
|
||||||
|
* It's possible that the event was signaled because the
|
||||||
|
* other side of pipe was closed.
|
||||||
|
*/
|
||||||
|
if (Fcb->PipeState != FILE_PIPE_CONNECTED_STATE)
|
||||||
|
{
|
||||||
|
DPRINT("PipeState: %x\n", Fcb->PipeState);
|
||||||
|
Status = STATUS_PIPE_BROKEN;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
KeAcquireSpinLock(&ReadFcb->DataListLock, &OldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pipe->PipeReadMode == FILE_PIPE_BYTE_STREAM_MODE)
|
if (Pipe->PipeReadMode == FILE_PIPE_BYTE_STREAM_MODE)
|
||||||
|
@ -288,6 +298,16 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status);
|
DPRINT("Finished waiting (%S)! Status: %x\n", Pipe->PipeName.Buffer, Status);
|
||||||
|
/*
|
||||||
|
* It's possible that the event was signaled because the
|
||||||
|
* other side of pipe was closed.
|
||||||
|
*/
|
||||||
|
if (Fcb->PipeState != FILE_PIPE_CONNECTED_STATE)
|
||||||
|
{
|
||||||
|
DPRINT("PipeState: %x\n", Fcb->PipeState);
|
||||||
|
Status = STATUS_PIPE_BROKEN;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql);
|
KeAcquireSpinLock(&Fcb->DataListLock, &OldIrql);
|
||||||
}
|
}
|
||||||
if (Pipe->PipeWriteMode == FILE_PIPE_BYTE_STREAM_MODE)
|
if (Pipe->PipeWriteMode == FILE_PIPE_BYTE_STREAM_MODE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue