fix the issue of Inadequate Memory Allocation in Variable Services

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
This commit is contained in:
eric_tian 2009-06-03 08:48:09 +00:00
parent 2561f56540
commit bcd7070d86
2 changed files with 4 additions and 4 deletions

View File

@ -263,7 +263,7 @@ UpdateVariableInfo (
ASSERT (gVariableInfo != NULL); ASSERT (gVariableInfo != NULL);
CopyGuid (&gVariableInfo->VendorGuid, VendorGuid); CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);
gVariableInfo->Name = AllocatePool (StrLen (VariableName)); gVariableInfo->Name = AllocatePool (StrSize (VariableName));
ASSERT (gVariableInfo->Name != NULL); ASSERT (gVariableInfo->Name != NULL);
StrCpy (gVariableInfo->Name, VariableName); StrCpy (gVariableInfo->Name, VariableName);
gVariableInfo->Volatile = Volatile; gVariableInfo->Volatile = Volatile;
@ -301,7 +301,7 @@ UpdateVariableInfo (
ASSERT (Entry->Next != NULL); ASSERT (Entry->Next != NULL);
CopyGuid (&Entry->Next->VendorGuid, VendorGuid); CopyGuid (&Entry->Next->VendorGuid, VendorGuid);
Entry->Next->Name = AllocatePool (StrLen (VariableName)); Entry->Next->Name = AllocatePool (StrSize (VariableName));
ASSERT (Entry->Next->Name != NULL); ASSERT (Entry->Next->Name != NULL);
StrCpy (Entry->Next->Name, VariableName); StrCpy (Entry->Next->Name, VariableName);
Entry->Next->Volatile = Volatile; Entry->Next->Volatile = Volatile;

View File

@ -176,7 +176,7 @@ UpdateVariableInfo (
ASSERT (gVariableInfo != NULL); ASSERT (gVariableInfo != NULL);
CopyGuid (&gVariableInfo->VendorGuid, VendorGuid); CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);
gVariableInfo->Name = AllocatePool (StrLen (VariableName)); gVariableInfo->Name = AllocatePool (StrSize (VariableName));
ASSERT (gVariableInfo->Name != NULL); ASSERT (gVariableInfo->Name != NULL);
StrCpy (gVariableInfo->Name, VariableName); StrCpy (gVariableInfo->Name, VariableName);
gVariableInfo->Volatile = Volatile; gVariableInfo->Volatile = Volatile;
@ -214,7 +214,7 @@ UpdateVariableInfo (
ASSERT (Entry->Next != NULL); ASSERT (Entry->Next != NULL);
CopyGuid (&Entry->Next->VendorGuid, VendorGuid); CopyGuid (&Entry->Next->VendorGuid, VendorGuid);
Entry->Next->Name = AllocatePool (StrLen (VariableName)); Entry->Next->Name = AllocatePool (StrSize (VariableName));
ASSERT (Entry->Next->Name != NULL); ASSERT (Entry->Next->Name != NULL);
StrCpy (Entry->Next->Name, VariableName); StrCpy (Entry->Next->Name, VariableName);
Entry->Next->Volatile = Volatile; Entry->Next->Volatile = Volatile;