From 446441503d46b0b4955bd1f19c60532299dc3d4e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 1 Feb 2005 21:21:33 +0000 Subject: [PATCH] Protect against writes beyond the end of partition. svn path=/trunk/; revision=13386 --- reactos/drivers/storage/disk/disk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reactos/drivers/storage/disk/disk.c b/reactos/drivers/storage/disk/disk.c index e2910de8862..2d68cf862a0 100644 --- a/reactos/drivers/storage/disk/disk.c +++ b/reactos/drivers/storage/disk/disk.c @@ -390,6 +390,8 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject, { PDEVICE_EXTENSION DeviceExtension; PDISK_DATA DiskData; + PIO_STACK_LOCATION IrpStack; + ULARGE_INTEGER EndingOffset; DPRINT("DiskClassCheckReadWrite() called\n"); @@ -404,6 +406,16 @@ DiskClassCheckReadWrite(IN PDEVICE_OBJECT DeviceObject, 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); }