[NTOS:CC] Don't read past the end of the file in CcPerformReadAhead. 390/head
authorThomas Faber <thomas.faber@reactos.org>
Tue, 20 Feb 2018 12:49:54 +0000 (13:49 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 22 Feb 2018 13:03:05 +0000 (14:03 +0100)
ntoskrnl/cc/copy.c

index 4328777..496cef6 100644 (file)
@@ -517,6 +517,16 @@ CcPerformReadAhead(
     /* Remember it's locked */
     Locked = TRUE;
 
+    /* Don't read past the end of the file */
+    if (CurrentOffset >= SharedCacheMap->FileSize.QuadPart)
+    {
+        goto Clear;
+    }
+    if (CurrentOffset + Length > SharedCacheMap->FileSize.QuadPart)
+    {
+        Length = SharedCacheMap->FileSize.QuadPart - CurrentOffset;
+    }
+
     /* Next of the algorithm will lock like CcCopyData with the slight
      * difference that we don't copy data back to an user-backed buffer
      * We just bring data into Cc