From 3aa5dd5be2f6ef5efaebc1d93e3762648a469edf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 13 Jun 2004 14:05:53 +0000 Subject: [PATCH] - Fixed list traversing in MmAlterRegion to correctly handle Length that is greater than real memory area size. svn path=/trunk/; revision=9663 --- reactos/ntoskrnl/mm/region.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/mm/region.c b/reactos/ntoskrnl/mm/region.c index 4dae3a96d7f..f27cb55c122 100644 --- a/reactos/ntoskrnl/mm/region.c +++ b/reactos/ntoskrnl/mm/region.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: region.c,v 1.7 2004/04/10 22:35:25 gdalsnes Exp $ +/* $Id: region.c,v 1.8 2004/06/13 14:05:53 navaraf Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/region.c @@ -160,6 +160,7 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, { RemainingLength = 0; } + /* * If necessary then split the region into the affected and unaffected parts. */ @@ -186,7 +187,8 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, CurrentRegion = CONTAINING_RECORD(CurrentEntry, MM_REGION, RegionListEntry); CurrentBaseAddress = (char*)StartAddress + NewRegion->Length; - while (RemainingLength > 0 && CurrentRegion->Length <= RemainingLength) + while (RemainingLength > 0 && CurrentRegion->Length <= RemainingLength && + CurrentEntry != RegionListHead) { if (CurrentRegion->Type != NewType && CurrentRegion->Protect != NewProtect) @@ -217,7 +219,7 @@ MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, /* * Split any final region. */ - if (RemainingLength > 0) + if (RemainingLength > 0 && CurrentEntry != RegionListHead) { CurrentRegion = CONTAINING_RECORD(CurrentEntry, MM_REGION, RegionListEntry);