mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:45:40 +00:00
[KMTESTS:IO] Avoid crashing in IoCreateFile test when pool allocations are failed
This commit is contained in:
parent
5ba5051f79
commit
188f5dc50a
1 changed files with 34 additions and 18 deletions
|
@ -94,10 +94,15 @@ TestIrpHandler(
|
||||||
{
|
{
|
||||||
PREPARSE_DATA_BUFFER Reparse;
|
PREPARSE_DATA_BUFFER Reparse;
|
||||||
|
|
||||||
Irp->Tail.Overlay.AuxiliaryBuffer = ExAllocatePoolWithTag(NonPagedPool, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, 'FwrI');
|
Irp->Tail.Overlay.AuxiliaryBuffer = ExAllocatePoolZero(NonPagedPool, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, 'FwrI');
|
||||||
Reparse = (PREPARSE_DATA_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
|
Reparse = (PREPARSE_DATA_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
|
||||||
|
|
||||||
RtlZeroMemory(Reparse, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
|
if (!Reparse)
|
||||||
|
{
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto Finish;
|
||||||
|
}
|
||||||
|
|
||||||
Reparse->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
|
Reparse->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
|
||||||
Reparse->ReparseDataLength = 12 + sizeof(L"\\??\\C:\\Documents and Settings");
|
Reparse->ReparseDataLength = 12 + sizeof(L"\\??\\C:\\Documents and Settings");
|
||||||
Reparse->MountPointReparseBuffer.SubstituteNameLength = sizeof(L"\\??\\C:\\Documents and Settings") - sizeof(UNICODE_NULL);
|
Reparse->MountPointReparseBuffer.SubstituteNameLength = sizeof(L"\\??\\C:\\Documents and Settings") - sizeof(UNICODE_NULL);
|
||||||
|
@ -109,18 +114,23 @@ TestIrpHandler(
|
||||||
else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
|
else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
|
||||||
IoStack->FileObject->FileName.Buffer[1] == 'S')
|
IoStack->FileObject->FileName.Buffer[1] == 'S')
|
||||||
{
|
{
|
||||||
|
PREPARSE_DATA_BUFFER Reparse;
|
||||||
|
|
||||||
if (IoStack->Flags & SL_STOP_ON_SYMLINK)
|
if (IoStack->Flags & SL_STOP_ON_SYMLINK)
|
||||||
{
|
{
|
||||||
Status = STATUS_STOPPED_ON_SYMLINK;
|
Status = STATUS_STOPPED_ON_SYMLINK;
|
||||||
|
goto Finish;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
PREPARSE_DATA_BUFFER Reparse;
|
|
||||||
|
|
||||||
Irp->Tail.Overlay.AuxiliaryBuffer = ExAllocatePoolWithTag(NonPagedPool, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, 'FwrI');
|
Irp->Tail.Overlay.AuxiliaryBuffer = ExAllocatePoolZero(NonPagedPool, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, 'FwrI');
|
||||||
Reparse = (PREPARSE_DATA_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
|
Reparse = (PREPARSE_DATA_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
|
||||||
|
|
||||||
RtlZeroMemory(Reparse, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
|
if (!Reparse)
|
||||||
|
{
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto Finish;
|
||||||
|
}
|
||||||
|
|
||||||
Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
|
Reparse->ReparseTag = IO_REPARSE_TAG_SYMLINK;
|
||||||
Reparse->ReparseDataLength = 12 + sizeof(L"\\??\\C:\\Documents and Settings");
|
Reparse->ReparseDataLength = 12 + sizeof(L"\\??\\C:\\Documents and Settings");
|
||||||
Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength = sizeof(L"\\??\\C:\\Documents and Settings") - sizeof(UNICODE_NULL);
|
Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength = sizeof(L"\\??\\C:\\Documents and Settings") - sizeof(UNICODE_NULL);
|
||||||
|
@ -129,11 +139,16 @@ TestIrpHandler(
|
||||||
Irp->IoStatus.Information = IO_REPARSE_TAG_SYMLINK;
|
Irp->IoStatus.Information = IO_REPARSE_TAG_SYMLINK;
|
||||||
Status = STATUS_REPARSE;
|
Status = STATUS_REPARSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Fcb), 'FwrI');
|
Fcb = ExAllocatePoolZero(NonPagedPool, sizeof(*Fcb), 'FwrI');
|
||||||
RtlZeroMemory(Fcb, sizeof(*Fcb));
|
|
||||||
|
if (!Fcb)
|
||||||
|
{
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto Finish;
|
||||||
|
}
|
||||||
|
|
||||||
ExInitializeFastMutex(&Fcb->HeaderMutex);
|
ExInitializeFastMutex(&Fcb->HeaderMutex);
|
||||||
FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
|
FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
|
||||||
Fcb->Header.AllocationSize.QuadPart = 0;
|
Fcb->Header.AllocationSize.QuadPart = 0;
|
||||||
|
@ -157,6 +172,7 @@ TestIrpHandler(
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Finish:
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue