Don't attempt to read beyond stream size.
Patch by Trevor Thompson.

CORE-11707

svn path=/trunk/; revision=72067
This commit is contained in:
Pierre Schweitzer 2016-08-01 06:14:45 +00:00
parent 96fe018e77
commit 21652b5c7f

View file

@ -147,7 +147,10 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
RealLength = ROUND_UP(ToRead, DeviceExt->NtfsInfo.BytesPerSector); RealLength = ROUND_UP(ToRead, DeviceExt->NtfsInfo.BytesPerSector);
/* do we need to extend RealLength by one sector? */ /* do we need to extend RealLength by one sector? */
if (RealLength + RealReadOffset < ReadOffset + Length) if (RealLength + RealReadOffset < ReadOffset + Length)
RealLength += DeviceExt->NtfsInfo.BytesPerSector; {
if (RealReadOffset + RealLength + DeviceExt->NtfsInfo.BytesPerSector <= AttributeAllocatedLength(&DataContext->Record))
RealLength += DeviceExt->NtfsInfo.BytesPerSector;
}
ReadBuffer = ExAllocatePoolWithTag(NonPagedPool, RealLength, TAG_NTFS); ReadBuffer = ExAllocatePoolWithTag(NonPagedPool, RealLength, TAG_NTFS);