mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTOS:MM] Fix more 64 bit arithmetics
This commit is contained in:
parent
6bab72f69a
commit
96ae15ac4b
1 changed files with 20 additions and 9 deletions
|
@ -1299,6 +1299,14 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
|||
{
|
||||
/* The caller did not, so pick a 64K aligned view size based on the offset */
|
||||
SectionOffset->LowPart &= ~(_64K - 1);
|
||||
|
||||
/* Make sure that we will not overflow */
|
||||
if ((Section->SizeOfSection.QuadPart - SectionOffset->QuadPart) > MAXLONG_PTR)
|
||||
{
|
||||
MiDereferenceControlArea(ControlArea);
|
||||
return STATUS_INVALID_VIEW_SIZE;
|
||||
}
|
||||
|
||||
*ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
|
||||
}
|
||||
else
|
||||
|
@ -1306,6 +1314,13 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
|||
/* A size was specified, align it to a 64K boundary */
|
||||
*ViewSize += SectionOffset->LowPart & (_64K - 1);
|
||||
|
||||
/* Check for overflow or huge value */
|
||||
if ((*ViewSize < (SectionOffset->LowPart & (_64K - 1))) || ((*ViewSize) > MAXLONG_PTR))
|
||||
{
|
||||
MiDereferenceControlArea(ControlArea);
|
||||
return STATUS_INVALID_VIEW_SIZE;
|
||||
}
|
||||
|
||||
/* Align the offset as well to make this an aligned map */
|
||||
SectionOffset->LowPart &= ~((ULONG)_64K - 1);
|
||||
}
|
||||
|
@ -1313,13 +1328,6 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
|
|||
/* We must be dealing with a 64KB aligned offset. This is a Windows ASSERT */
|
||||
ASSERT((SectionOffset->LowPart & ((ULONG)_64K - 1)) == 0);
|
||||
|
||||
/* It's illegal to try to map more than overflows a LONG_PTR */
|
||||
if (*ViewSize >= MAXLONG_PTR)
|
||||
{
|
||||
MiDereferenceControlArea(ControlArea);
|
||||
return STATUS_INVALID_VIEW_SIZE;
|
||||
}
|
||||
|
||||
/* Windows ASSERTs for this flag */
|
||||
ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0);
|
||||
|
||||
|
@ -1535,7 +1543,10 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
|
|||
SizeLimit <<= PAGE_SHIFT;
|
||||
|
||||
/* Fail if this size is too big */
|
||||
if (MaximumSize->QuadPart > SizeLimit) return STATUS_SECTION_TOO_BIG;
|
||||
if (MaximumSize->QuadPart > SizeLimit)
|
||||
{
|
||||
return STATUS_SECTION_TOO_BIG;
|
||||
}
|
||||
|
||||
/* Calculate how many Prototype PTEs will be needed */
|
||||
PteCount = (PFN_COUNT)((MaximumSize->QuadPart + PAGE_SIZE - 1) >> PAGE_SHIFT);
|
||||
|
@ -1592,7 +1603,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
|
|||
|
||||
/* Save some extra accounting data for the segment as well */
|
||||
NewSegment->u1.CreatingProcess = PsGetCurrentProcess();
|
||||
NewSegment->SizeOfSegment = PteCount * PAGE_SIZE;
|
||||
NewSegment->SizeOfSegment = ((ULONGLONG)PteCount) * PAGE_SIZE;
|
||||
NewSegment->TotalNumberOfPtes = PteCount;
|
||||
NewSegment->NonExtendedPtes = PteCount;
|
||||
|
||||
|
|
Loading…
Reference in a new issue