diff --git a/reactos/drivers/filesystems/ntfs/rw.c b/reactos/drivers/filesystems/ntfs/rw.c index 13e9d86595e..e74d5a6b64f 100644 --- a/reactos/drivers/filesystems/ntfs/rw.c +++ b/reactos/drivers/filesystems/ntfs/rw.c @@ -145,8 +145,12 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt, { RealReadOffset = ROUND_DOWN(ReadOffset, DeviceExt->NtfsInfo.BytesPerSector); RealLength = ROUND_UP(ToRead, DeviceExt->NtfsInfo.BytesPerSector); + /* do we need to extend RealLength by one sector? */ + if (RealLength + RealReadOffset < ReadOffset + Length) + RealLength += DeviceExt->NtfsInfo.BytesPerSector; - ReadBuffer = ExAllocatePoolWithTag(NonPagedPool, RealLength + DeviceExt->NtfsInfo.BytesPerSector, TAG_NTFS); + + ReadBuffer = ExAllocatePoolWithTag(NonPagedPool, RealLength + (DeviceExt->NtfsInfo.BytesPerSector * 2), TAG_NTFS); if (ReadBuffer == NULL) { DPRINT1("Not enough memory!\n");