https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a2f77ee3fb74553744f95…
commit a2f77ee3fb74553744f95d5ef0963cadda97302f
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Tue Feb 20 13:49:54 2018 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Thu Feb 22 14:03:05 2018 +0100
[NTOS:CC] Don't read past the end of the file in CcPerformReadAhead.
---
ntoskrnl/cc/copy.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index 43287774a3..496cef6d4d 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -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