From b350dffe6c7deb715458bd7a912498aacdd7b389 Mon Sep 17 00:00:00 2001 From: "Felix A. Croes" Date: Thu, 7 Mar 2019 09:45:42 +0100 Subject: [PATCH] Fix 32 bit overflow issue in FspFsvolReadCached. FspFsvolReadCached takes care not to read beyond the end of the file. However, the offset check uses a 32 bit comparison, which fails for files >= 4G. As a result, reads on a large file will skip blocks at offset (filesize % 4G), and those blocks will zero-filled. --- src/sys/read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys/read.c b/src/sys/read.c index 8410d9d4..697c72ad 100644 --- a/src/sys/read.c +++ b/src/sys/read.c @@ -150,7 +150,7 @@ static NTSTATUS FspFsvolReadCached( FspFileNodeRelease(FileNode, Main); return STATUS_END_OF_FILE; } - if (ReadLength > (ULONG)(FileInfo.FileSize - ReadOffset.QuadPart)) + if ((UINT64)ReadLength > FileInfo.FileSize - ReadOffset.QuadPart) ReadLength = (ULONG)(FileInfo.FileSize - ReadOffset.QuadPart); /* initialize cache if not already initialized! */