From: Thomas Faber Date: Tue, 20 Feb 2018 12:49:54 +0000 (+0100) Subject: [NTOS:CC] Don't read past the end of the file in CcPerformReadAhead. X-Git-Tag: 0.4.9-RC~755 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=a2f77ee3fb74553744f95d5ef0963cadda97302f [NTOS:CC] Don't read past the end of the file in CcPerformReadAhead. --- diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 43287774a3a..496cef6d4d9 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