From e32b96e4aa0f98cffecc42f5ac0d407699c5fba6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 2 May 2009 20:46:50 +0000 Subject: [PATCH] - Fix memory corruption when reading binary data svn path=/trunk/; revision=40773 --- reactos/drivers/network/ndis/ndis/config.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/network/ndis/ndis/config.c b/reactos/drivers/network/ndis/ndis/config.c index e84c2db37c4..76db210b3cb 100644 --- a/reactos/drivers/network/ndis/ndis/config.c +++ b/reactos/drivers/network/ndis/ndis/config.c @@ -615,14 +615,24 @@ NdisReadConfiguration( return; } + (*ParameterValue)->ParameterData.BinaryData.Buffer = ExAllocatePool(PagedPool, KeyInformation->DataLength); + if (!(*ParameterValue)->ParameterData.BinaryData.Buffer) + { + NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n")); + ExFreePool(KeyInformation); + *Status = NDIS_STATUS_RESOURCES; + return; + } + + (*ParameterValue)->ParameterType = ParameterType; + (*ParameterValue)->ParameterData.BinaryData.Length = KeyInformation->DataLength; + memcpy((*ParameterValue)->ParameterData.BinaryData.Buffer, KeyInformation->Data, KeyInformation->DataLength); + MiniportResource->ResourceType = 0; MiniportResource->Resource = *ParameterValue; NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n", MiniportResource->Resource)); ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead, &MiniportResource->ListEntry, &ConfigurationContext->ResourceLock); - (*ParameterValue)->ParameterType = ParameterType; - memcpy(&((*ParameterValue)->ParameterData.BinaryData), KeyInformation->Data, KeyInformation->DataLength); - ExFreePool(KeyInformation); *Status = NDIS_STATUS_SUCCESS;