Author: cgutman
Date: Sun May 3 00:46:50 2009
New Revision: 40773
URL:
http://svn.reactos.org/svn/reactos?rev=40773&view=rev
Log:
- Fix memory corruption when reading binary data
Modified:
trunk/reactos/drivers/network/ndis/ndis/config.c
Modified: trunk/reactos/drivers/network/ndis/ndis/config.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] Sun May 3 00:46:50
2009
@@ -615,13 +615,23 @@
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);