https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f43a7b81a7cbab29ffe4ed31cafa6550f353440a
commit f43a7b81a7cbab29ffe4ed31cafa6550f353440a Author: Timo Kreuzer <[email protected]> AuthorDate: Tue Aug 21 11:25:22 2018 +0200 Commit: GitHub <[email protected]> CommitDate: Tue Aug 21 11:25:22 2018 +0200 [NTOS:Mm] Fix a 64 bit issue in MmMapViewOfArm3Section (#778) Fixes a Clang-Cl warning CORE-14306 --- ntoskrnl/mm/ARM3/section.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 689f6cd86f..f1912253d9 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -9,6 +9,7 @@ /* INCLUDES *******************************************************************/ #include <ntoskrnl.h> +#include <ntintsafe.h> #define NDEBUG #include <debug.h> @@ -2847,6 +2848,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, PCONTROL_AREA ControlArea; ULONG ProtectionMask; NTSTATUS Status; + ULONG64 CalculatedViewSize; PAGED_CODE(); /* Get the segment and control area */ @@ -2893,11 +2895,12 @@ MmMapViewOfArm3Section(IN PVOID SectionObject, if (!(*ViewSize)) { /* Compute it for the caller */ - *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart); + CalculatedViewSize = Section->SizeOfSection.QuadPart - + SectionOffset->QuadPart; /* Check if it's larger than 4GB or overflows into kernel-mode */ - if ((*ViewSize > 0xFFFFFFFF) || - (((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - (ULONG_PTR)*BaseAddress) < *ViewSize)) + if (!NT_SUCCESS(RtlULongLongToSIZET(CalculatedViewSize, ViewSize)) || + (((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - (ULONG_PTR)*BaseAddress) < CalculatedViewSize)) { DPRINT1("Section view won't fit\n"); return STATUS_INVALID_VIEW_SIZE;
