[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Mon, 1 Aug 2016 06:14:45 +0000 (06:14 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 1 Aug 2016 06:14:45 +0000 (06:14 +0000)
Don't attempt to read beyond stream size.
Patch by Trevor Thompson.

CORE-11707

svn path=/trunk/; revision=72067

reactos/drivers/filesystems/ntfs/rw.c

index be5ec28..0437b61 100644 (file)
@@ -147,7 +147,10 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
         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;
+        {
+            if (RealReadOffset + RealLength + DeviceExt->NtfsInfo.BytesPerSector <= AttributeAllocatedLength(&DataContext->Record))
+                RealLength += DeviceExt->NtfsInfo.BytesPerSector;
+        }
 
 
         ReadBuffer = ExAllocatePoolWithTag(NonPagedPool, RealLength, TAG_NTFS);