From e305e4d354d725ec62b1bafc6277170def7f8375 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Wed, 15 Jun 2016 13:35:14 +0800 Subject: MdeModulePkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr It is the follow up of 3ab41b7a325ca11a12b42f5ad1661c4b6791cb49 to replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr with UnicodeStrToAsciiStrS/AsciiStrToUnicodeStrS. (We integrate the change for FrontPageCustomizedUiSupport.c in commit b68ccac17c7e6340ab7b3654ea51c86ad6b4201d on master to FrontPage.c on UDK2015 branch) (We integrate the change for BmBootDescription.c in commit b68ccac17c7e6340ab7b3654ea51c86ad6b4201d on master to BmBoot.c on UDK2015 branch) Cc: Jiewen Yao Cc: Liming Gao Cc: Eric Dong Cc: Feng Tian Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jaben Carsey (cherry picked from commit b68ccac17c7e6340ab7b3654ea51c86ad6b4201d) --- MdeModulePkg/Application/UiApp/FrontPage.c | 8 ++-- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 18 ++++++--- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 4 +- .../Library/VarCheckHiiLib/VarCheckHiiGen.c | 6 +-- .../HiiDatabaseDxe/ConfigKeywordHandler.c | 46 ++++++++++++++-------- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 42 +++++++++++++------- 6 files changed, 78 insertions(+), 46 deletions(-) diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c index 245c3497c8..906c5900de 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.c +++ b/MdeModulePkg/Application/UiApp/FrontPage.c @@ -175,6 +175,7 @@ InitializeLanguage ( EFI_STATUS Status; CHAR8 *LangCode; CHAR8 *Lang; + UINTN LangSize; CHAR8 *CurrentLang; UINTN OptionCount; CHAR16 *StringBuffer; @@ -272,9 +273,10 @@ InitializeLanguage ( } if (EFI_ERROR (Status)) { - StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16)); + LangSize = AsciiStrSize (Lang); + StringBuffer = AllocatePool (LangSize * sizeof (CHAR16)); ASSERT (StringBuffer != NULL); - AsciiStrToUnicodeStr (Lang, StringBuffer); + AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize); } ASSERT (StringBuffer != NULL); @@ -734,7 +736,7 @@ GetOptionalStringByIndex ( *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING)); } else { *String = AllocatePool (StrSize * sizeof (CHAR16)); - AsciiStrToUnicodeStr (OptionalStrStart, *String); + AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize); } return EFI_SUCCESS; diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index e112d45ef2..6a84847039 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2976,18 +2976,20 @@ NetLibStrToIp4 ( ) { CHAR8 *Ip4Str; + UINTN StringSize; EFI_STATUS Status; if ((String == NULL) || (Ip4Address == NULL)) { return EFI_INVALID_PARAMETER; } - Ip4Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8)); + StringSize = StrLen (String) + 1; + Ip4Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8)); if (Ip4Str == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (String, Ip4Str); + UnicodeStrToAsciiStrS (String, Ip4Str, StringSize); Status = NetLibAsciiStrToIp4 (Ip4Str, Ip4Address); @@ -3017,18 +3019,20 @@ NetLibStrToIp6 ( ) { CHAR8 *Ip6Str; + UINTN StringSize; EFI_STATUS Status; if ((String == NULL) || (Ip6Address == NULL)) { return EFI_INVALID_PARAMETER; } - Ip6Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8)); + StringSize = StrLen (String) + 1; + Ip6Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8)); if (Ip6Str == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (String, Ip6Str); + UnicodeStrToAsciiStrS (String, Ip6Str, StringSize); Status = NetLibAsciiStrToIp6 (Ip6Str, Ip6Address); @@ -3060,6 +3064,7 @@ NetLibStrToIp6andPrefix ( ) { CHAR8 *Ip6Str; + UINTN StringSize; CHAR8 *PrefixStr; CHAR8 *TempStr; EFI_STATUS Status; @@ -3069,12 +3074,13 @@ NetLibStrToIp6andPrefix ( return EFI_INVALID_PARAMETER; } - Ip6Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8)); + StringSize = StrLen (String) + 1; + Ip6Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8)); if (Ip6Str == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (String, Ip6Str); + UnicodeStrToAsciiStrS (String, Ip6Str, StringSize); // // Get the sub string describing prefix length. diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 59366885c4..52f2d038f3 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -542,7 +542,7 @@ BmGetDescriptionFromDiskInfo ( StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]); Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH]; StrPtr[VENDOR_IDENTIFICATION_LENGTH] = '\0'; - AsciiStrToUnicodeStr (StrPtr, Description); + AsciiStrToUnicodeStrS (StrPtr, Description, VENDOR_IDENTIFICATION_LENGTH + 1); StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp; // @@ -552,7 +552,7 @@ BmGetDescriptionFromDiskInfo ( StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]); StrPtr[PRODUCT_IDENTIFICATION_LENGTH] = '\0'; - AsciiStrToUnicodeStr (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1); + AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1); BmEliminateExtraSpaces (Description); } diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index 725ccc7d78..cab92967aa 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -1,7 +1,7 @@ /** @file Var Check Hii bin generation. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1130,13 +1130,13 @@ CreateHiiVariableNode ( // // Get variable name. // - VarNameSize = AsciiStrSize ((CHAR8 *) IfrEfiVarStore->Name) * 2; + VarNameSize = AsciiStrSize ((CHAR8 *) IfrEfiVarStore->Name) * sizeof (CHAR16); if (VarNameSize > mMaxVarNameSize) { mVarName = InternalVarCheckReallocatePool (mMaxVarNameSize, VarNameSize, mVarName); ASSERT (mVarName != NULL); mMaxVarNameSize = VarNameSize; } - AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, mVarName); + AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, mVarName, mMaxVarNameSize / sizeof (CHAR16)); VarName = mVarName; HiiVariableNode = FindHiiVariableNode ( diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c index 0deaf20557..ce2216517c 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c @@ -178,6 +178,7 @@ ExtractNameSpace ( ) { CHAR16 *TmpPtr; + UINTN NameSpaceSize; ASSERT (NameSpace != NULL); @@ -218,11 +219,12 @@ ExtractNameSpace ( // Input NameSpace is unicode string. The language in String package is ascii string. // Here will convert the unicode string to ascii and save it. // - *NameSpace = AllocatePool (StrLen (String) + 1); + NameSpaceSize = StrLen (String) + 1; + *NameSpace = AllocatePool (NameSpaceSize); if (*NameSpace == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr (String, *NameSpace); + UnicodeStrToAsciiStrS (String, *NameSpace, NameSpaceSize); if (TmpPtr != NULL) { *TmpPtr = L'&'; @@ -779,6 +781,7 @@ GetStringIdFromString ( UINTN StringSize; CHAR16 *String; CHAR8 *AsciiKeywordValue; + UINTN KeywordValueSize; EFI_STATUS Status; ASSERT (StringPackage != NULL && KeywordValue != NULL && StringId != NULL); @@ -794,11 +797,12 @@ GetStringIdFromString ( // // Make a ascii keyword value for later use. // - AsciiKeywordValue = AllocatePool (StrLen (KeywordValue) + 1); + KeywordValueSize = StrLen (KeywordValue) + 1; + AsciiKeywordValue = AllocatePool (KeywordValueSize); if (AsciiKeywordValue == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStr(KeywordValue, AsciiKeywordValue); + UnicodeStrToAsciiStrS (KeywordValue, AsciiKeywordValue, KeywordValueSize); while (*BlockHdr != EFI_HII_SIBT_END) { switch (*BlockHdr) { @@ -1065,11 +1069,12 @@ GetNextStringId ( StringTextPtr = BlockHdr + Offset; if (FindString) { - *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16)); + StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr); + *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16)); if (*KeywordValue == NULL) { return 0; } - AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue); + AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize); return CurrentStringId; } else if (CurrentStringId == StringId) { FindString = TRUE; @@ -1084,11 +1089,12 @@ GetNextStringId ( StringTextPtr = BlockHdr + Offset; if (FindString) { - *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16)); + StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr); + *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16)); if (*KeywordValue == NULL) { return 0; } - AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue); + AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize); return CurrentStringId; } else if (CurrentStringId == StringId) { FindString = TRUE; @@ -1105,11 +1111,12 @@ GetNextStringId ( for (Index = 0; Index < StringCount; Index++) { if (FindString) { - *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16)); + StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr); + *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16)); if (*KeywordValue == NULL) { return 0; } - AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue); + AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize); return CurrentStringId; } else if (CurrentStringId == StringId) { FindString = TRUE; @@ -1132,11 +1139,12 @@ GetNextStringId ( for (Index = 0; Index < StringCount; Index++) { if (FindString) { - *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16)); + StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr); + *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16)); if (*KeywordValue == NULL) { return 0; } - AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue); + AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize); return CurrentStringId; } else if (CurrentStringId == StringId) { FindString = TRUE; @@ -1670,6 +1678,7 @@ ConstructConfigHdr ( UINT8 *Buffer; CHAR16 *Name; CHAR8 *AsciiName; + UINTN NameSize; EFI_GUID *Guid; UINTN MaxLen; @@ -1699,9 +1708,10 @@ ConstructConfigHdr ( } if (AsciiName != NULL) { - Name = AllocateZeroPool (AsciiStrSize (AsciiName) * 2); + NameSize = AsciiStrSize (AsciiName); + Name = AllocateZeroPool (NameSize * sizeof (CHAR16)); ASSERT (Name != NULL); - AsciiStrToUnicodeStr(AsciiName, Name); + AsciiStrToUnicodeStrS (AsciiName, Name, NameSize); } else { Name = NULL; } @@ -2375,6 +2385,7 @@ GenerateKeywordResp ( CHAR16 *RespStr; CHAR16 *PathHdr; CHAR16 *UnicodeNameSpace; + UINTN NameSpaceLength; ASSERT ((NameSpace != NULL) && (DevicePath != NULL) && (KeywordData != NULL) && (ValueStr != NULL) && (KeywordResp != NULL)); @@ -2385,12 +2396,13 @@ GenerateKeywordResp ( // 1.1 NameSpaceId size. // 'NAMESPACE=' // - RespStrLen = 10 + AsciiStrLen (NameSpace); - UnicodeNameSpace = AllocatePool ((AsciiStrLen (NameSpace) + 1) * sizeof (CHAR16)); + NameSpaceLength = AsciiStrLen (NameSpace); + RespStrLen = 10 + NameSpaceLength; + UnicodeNameSpace = AllocatePool ((NameSpaceLength + 1) * sizeof (CHAR16)); if (UnicodeNameSpace == NULL) { return EFI_OUT_OF_RESOURCES; } - AsciiStrToUnicodeStr(NameSpace, UnicodeNameSpace); + AsciiStrToUnicodeStrS (NameSpace, UnicodeNameSpace, NameSpaceLength + 1); // // 1.2 PathHdr size. diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index b618903b6a..2f53197d46 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1121,6 +1121,7 @@ GetVarStoreType ( UINTN PackageOffset; EFI_IFR_OP_HEADER *IfrOpHdr; CHAR16 *VarStoreName; + UINTN NameSize; EFI_STRING GuidStr; EFI_STRING NameStr; EFI_STRING TempStr; @@ -1175,12 +1176,13 @@ GetVarStoreType ( continue; } - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName, NameSize); GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrEfiVarStore->Guid, 1, &GuidStr); GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr); @@ -1353,6 +1355,7 @@ IsThisPackageList ( UINTN PackageOffset; EFI_IFR_OP_HEADER *IfrOpHdr; CHAR16 *VarStoreName; + UINTN NameSize; UINT8 *HiiFormPackage; UINTN PackageSize; EFI_IFR_VARSTORE_EFI *IfrEfiVarStore; @@ -1397,11 +1400,12 @@ IsThisPackageList ( case EFI_IFR_VARSTORE_OP: IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize); if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { FindVarstore = TRUE; @@ -1411,11 +1415,12 @@ IsThisPackageList ( case EFI_IFR_VARSTORE_EFI_OP: IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize); if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { FindVarstore = TRUE; @@ -1596,6 +1601,7 @@ ParseIfrData ( IFR_DEFAULT_DATA *DefaultDataPtr; IFR_BLOCK_DATA *BlockData; CHAR16 *VarStoreName; + UINTN NameSize; UINT16 VarWidth; UINT16 VarDefaultId; BOOLEAN FirstOneOfOption; @@ -1653,12 +1659,13 @@ ParseIfrData ( IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr; - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize); if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { // @@ -1691,12 +1698,13 @@ ParseIfrData ( break; } - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize); if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { // @@ -3355,6 +3363,7 @@ GetConfigRespFromEfiVarStore ( { EFI_STATUS Status; EFI_STRING VarStoreName; + UINTN NameSize; UINT8 *VarStore; UINTN BufferSize; @@ -3363,13 +3372,14 @@ GetConfigRespFromEfiVarStore ( VarStore = NULL; VarStoreName = NULL; *AccessProgress = Request; - - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16)); + + NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize); Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL); @@ -3430,6 +3440,7 @@ RouteConfigRespForEfiVarStore ( { EFI_STATUS Status; EFI_STRING VarStoreName; + UINTN NameSize; UINT8 *VarStore; UINTN BufferSize; UINTN BlockSize; @@ -3439,12 +3450,13 @@ RouteConfigRespForEfiVarStore ( VarStore = NULL; VarStoreName = NULL; - VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16)); + NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name); + VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16)); if (VarStoreName == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } - AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName); + AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize); Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL); if (Status != EFI_BUFFER_TOO_SMALL) { -- cgit v1.2.3