Protect against writes beyond the end of partition.

svn path=/trunk/; revision=13386
This commit is contained in:
Filip Navara 2005-02-01 21:21:33 +00:00
parent 02f0f81fc0
commit 446441503d

View file

@ -390,6 +390,8 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject,
{ {
PDEVICE_EXTENSION DeviceExtension; PDEVICE_EXTENSION DeviceExtension;
PDISK_DATA DiskData; PDISK_DATA DiskData;
PIO_STACK_LOCATION IrpStack;
ULARGE_INTEGER EndingOffset;
DPRINT("DiskClassCheckReadWrite() called\n"); DPRINT("DiskClassCheckReadWrite() called\n");
@ -404,6 +406,16 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject,
return(STATUS_INVALID_PARAMETER); return(STATUS_INVALID_PARAMETER);
} }
IrpStack = IoGetCurrentIrpStackLocation(Irp);
EndingOffset.QuadPart = IrpStack->Parameters.Read.ByteOffset.QuadPart +
IrpStack->Parameters.Read.Length;
if (EndingOffset.QuadPart > DeviceExtension->PartitionLength.QuadPart)
{
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
return(STATUS_INVALID_PARAMETER);
}
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }