]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fix the issue of Inadequate Memory Allocation in Variable Services
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 3 Jun 2009 08:48:09 +0000 (08:48 +0000)
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 3 Jun 2009 08:48:09 +0000 (08:48 +0000)
In UpdateVariableInfo(), the code incorrectly allocate a small memory, whose size equate with the number of Unicode name.
Should change it to be equal to the byte length of this Unicode name.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8457 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c

index cbf953dfe91522bfdf5b7939a035698e159ad7be..dddc14375192b41d4ef3204e8a3f7339b250f9a8 100644 (file)
@@ -263,7 +263,7 @@ UpdateVariableInfo (
       ASSERT (gVariableInfo != NULL);\r
 \r
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
-      gVariableInfo->Name = AllocatePool (StrLen (VariableName));\r
+      gVariableInfo->Name = AllocatePool (StrSize (VariableName));\r
       ASSERT (gVariableInfo->Name != NULL);\r
       StrCpy (gVariableInfo->Name, VariableName);\r
       gVariableInfo->Volatile = Volatile;\r
@@ -301,7 +301,7 @@ UpdateVariableInfo (
         ASSERT (Entry->Next != NULL);\r
 \r
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
-        Entry->Next->Name = AllocatePool (StrLen (VariableName));\r
+        Entry->Next->Name = AllocatePool (StrSize (VariableName));\r
         ASSERT (Entry->Next->Name != NULL);\r
         StrCpy (Entry->Next->Name, VariableName);\r
         Entry->Next->Volatile = Volatile;\r
index 02f146895fb6d9e86f138ec5bf08d958f1f74db9..aadda4b5879d2dc72ae8b123bcc8fdcb7bd8317a 100644 (file)
@@ -176,7 +176,7 @@ UpdateVariableInfo (
       ASSERT (gVariableInfo != NULL);\r
 \r
       CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
-      gVariableInfo->Name = AllocatePool (StrLen (VariableName));\r
+      gVariableInfo->Name = AllocatePool (StrSize (VariableName));\r
       ASSERT (gVariableInfo->Name != NULL);\r
       StrCpy (gVariableInfo->Name, VariableName);\r
       gVariableInfo->Volatile = Volatile;\r
@@ -214,7 +214,7 @@ UpdateVariableInfo (
         ASSERT (Entry->Next != NULL);\r
 \r
         CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
-        Entry->Next->Name = AllocatePool (StrLen (VariableName));\r
+        Entry->Next->Name = AllocatePool (StrSize (VariableName));\r
         ASSERT (Entry->Next->Name != NULL);\r
         StrCpy (Entry->Next->Name, VariableName);\r
         Entry->Next->Volatile = Volatile;\r