Author: tfaber Date: Sat Aug 6 09:07:03 2016 New Revision: 72127
URL: http://svn.reactos.org/svn/reactos?rev=72127&view=rev Log: [NTOS:MM] - Correctly check for overflow in PeFmtCreateSection CORE-11794
Modified: trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/mm/section.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=7... ============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sat Aug 6 09:07:03 2016 @@ -208,6 +208,7 @@ SIZE_T nPrevVirtualEndOfSegment = 0; ULONG nFileSizeOfHeaders = 0; ULONG i; + ULONG AlignedLength;
ASSERT(FileHeader); ASSERT(FileHeaderSize > 0); @@ -755,10 +756,11 @@ else pssSegments[i].Length.QuadPart = pishSectionHeaders[i].Misc.VirtualSize;
- pssSegments[i].Length.LowPart = ALIGN_UP_BY(pssSegments[i].Length.LowPart, nSectionAlignment); - /* FIXME: always false */ - if (pssSegments[i].Length.QuadPart < pssSegments[i].Length.QuadPart) + AlignedLength = ALIGN_UP_BY(pssSegments[i].Length.LowPart, nSectionAlignment); + if(AlignedLength < pssSegments[i].Length.LowPart) DIE(("Cannot align the virtual size of section %u\n", i)); + + pssSegments[i].Length.LowPart = AlignedLength;
if(pssSegments[i].Length.QuadPart == 0) DIE(("Virtual size of section %u is null\n", i));