mirror of
https://github.com/reactos/reactos.git
synced 2024-06-27 16:31:30 +00:00
[NTOSKRNL] Avoid integer overflow when computing VACB read/write size
This could be triggered when attempting to read/write to really big files. It was causing an attempt to read 0 bytes in Cc, leading to asserts failure in the kernel (and corrupted file). CORE-15067
This commit is contained in:
parent
ef016bfe0a
commit
15a3ca08b0
|
@ -86,12 +86,14 @@ CcReadVirtualAddress (
|
|||
NTSTATUS Status;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
KEVENT Event;
|
||||
ULARGE_INTEGER LargeSize;
|
||||
|
||||
Size = (ULONG)(Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart);
|
||||
if (Size > VACB_MAPPING_GRANULARITY)
|
||||
LargeSize.QuadPart = Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart;
|
||||
if (LargeSize.QuadPart > VACB_MAPPING_GRANULARITY)
|
||||
{
|
||||
Size = VACB_MAPPING_GRANULARITY;
|
||||
LargeSize.QuadPart = VACB_MAPPING_GRANULARITY;
|
||||
}
|
||||
Size = LargeSize.LowPart;
|
||||
|
||||
Pages = BYTES_TO_PAGES(Size);
|
||||
ASSERT(Pages * PAGE_SIZE <= VACB_MAPPING_GRANULARITY);
|
||||
|
@ -155,12 +157,14 @@ CcWriteVirtualAddress (
|
|||
NTSTATUS Status;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
KEVENT Event;
|
||||
ULARGE_INTEGER LargeSize;
|
||||
|
||||
Size = (ULONG)(Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart);
|
||||
if (Size > VACB_MAPPING_GRANULARITY)
|
||||
LargeSize.QuadPart = Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart;
|
||||
if (LargeSize.QuadPart > VACB_MAPPING_GRANULARITY)
|
||||
{
|
||||
Size = VACB_MAPPING_GRANULARITY;
|
||||
LargeSize.QuadPart = VACB_MAPPING_GRANULARITY;
|
||||
}
|
||||
Size = LargeSize.LowPart;
|
||||
//
|
||||
// Nonpaged pool PDEs in ReactOS must actually be synchronized between the
|
||||
// MmGlobalPageDirectory and the real system PDE directory. What a mess...
|
||||
|
|
Loading…
Reference in a new issue