*String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
} else {\r
*String = AllocatePool (StrSize * sizeof (CHAR16));\r
- AsciiStrToUnicodeStr (OptionalStrStart, *String);\r
+ AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize);\r
}\r
\r
return EFI_SUCCESS;\r
{\r
CHAR8 *LangCode;\r
CHAR8 *Lang;\r
+ UINTN LangSize;\r
CHAR8 *CurrentLang;\r
UINTN OptionCount;\r
CHAR16 *StringBuffer;\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16));\r
+ LangSize = AsciiStrSize (Lang);\r
+ StringBuffer = AllocatePool (LangSize * sizeof (CHAR16));\r
ASSERT (StringBuffer != NULL);\r
- AsciiStrToUnicodeStr (Lang, StringBuffer);\r
+ AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize);\r
}\r
\r
ASSERT (StringBuffer != NULL);\r
String[sizeof (Cid->OemId) + sizeof (Cid->ProductName)] = ' ';\r
CopyMem (String + sizeof (Cid->OemId) + sizeof (Cid->ProductName) + 1, Cid->ProductSerialNumber, sizeof (Cid->ProductSerialNumber));\r
\r
- AsciiStrToUnicodeStr (String, Device->ModelName);\r
+ AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));\r
\r
return EFI_SUCCESS;\r
}\r
String[sizeof (Cid->OemId) + sizeof (Cid->ProductName)] = ' ';\r
CopyMem (String + sizeof (Cid->OemId) + sizeof (Cid->ProductName) + 1, Cid->ProductSerialNumber, sizeof (Cid->ProductSerialNumber));\r
\r
- AsciiStrToUnicodeStr (String, Device->ModelName);\r
+ AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));\r
\r
return EFI_SUCCESS;\r
}\r
)\r
{\r
CHAR8 *Ip4Str;\r
+ UINTN StringSize;\r
EFI_STATUS Status;\r
\r
if ((String == NULL) || (Ip4Address == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Ip4Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8));\r
+ StringSize = StrLen (String) + 1;\r
+ Ip4Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8));\r
if (Ip4Str == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- UnicodeStrToAsciiStr (String, Ip4Str);\r
+ UnicodeStrToAsciiStrS (String, Ip4Str, StringSize);\r
\r
Status = NetLibAsciiStrToIp4 (Ip4Str, Ip4Address);\r
\r
)\r
{\r
CHAR8 *Ip6Str;\r
+ UINTN StringSize;\r
EFI_STATUS Status;\r
\r
if ((String == NULL) || (Ip6Address == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Ip6Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8));\r
+ StringSize = StrLen (String) + 1;\r
+ Ip6Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8));\r
if (Ip6Str == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- UnicodeStrToAsciiStr (String, Ip6Str);\r
+ UnicodeStrToAsciiStrS (String, Ip6Str, StringSize);\r
\r
Status = NetLibAsciiStrToIp6 (Ip6Str, Ip6Address);\r
\r
)\r
{\r
CHAR8 *Ip6Str;\r
+ UINTN StringSize;\r
CHAR8 *PrefixStr;\r
CHAR8 *TempStr;\r
EFI_STATUS Status;\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Ip6Str = (CHAR8 *) AllocatePool ((StrLen (String) + 1) * sizeof (CHAR8));\r
+ StringSize = StrLen (String) + 1;\r
+ Ip6Str = (CHAR8 *) AllocatePool (StringSize * sizeof (CHAR8));\r
if (Ip6Str == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- UnicodeStrToAsciiStr (String, Ip6Str);\r
+ UnicodeStrToAsciiStrS (String, Ip6Str, StringSize);\r
\r
//\r
// Get the sub string describing prefix length.\r
StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);\r
Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];\r
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = '\0';\r
- AsciiStrToUnicodeStr (StrPtr, Description);\r
+ AsciiStrToUnicodeStrS (StrPtr, Description, VENDOR_IDENTIFICATION_LENGTH + 1);\r
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp;\r
\r
//\r
\r
StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);\r
StrPtr[PRODUCT_IDENTIFICATION_LENGTH] = '\0';\r
- AsciiStrToUnicodeStr (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1);\r
+ AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1);\r
\r
BmEliminateExtraSpaces (Description);\r
}\r
/** @file\r
Var Check Hii bin generation.\r
\r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
//\r
// Get variable name.\r
//\r
- VarNameSize = AsciiStrSize ((CHAR8 *) IfrEfiVarStore->Name) * 2;\r
+ VarNameSize = AsciiStrSize ((CHAR8 *) IfrEfiVarStore->Name) * sizeof (CHAR16);\r
if (VarNameSize > mMaxVarNameSize) {\r
mVarName = InternalVarCheckReallocatePool (mMaxVarNameSize, VarNameSize, mVarName);\r
ASSERT (mVarName != NULL);\r
mMaxVarNameSize = VarNameSize;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, mVarName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, mVarName, mMaxVarNameSize / sizeof (CHAR16));\r
VarName = mVarName;\r
\r
HiiVariableNode = FindHiiVariableNode (\r
)\r
{\r
CHAR16 *TmpPtr;\r
+ UINTN NameSpaceSize;\r
\r
ASSERT (NameSpace != NULL);\r
\r
// Input NameSpace is unicode string. The language in String package is ascii string.\r
// Here will convert the unicode string to ascii and save it.\r
//\r
- *NameSpace = AllocatePool (StrLen (String) + 1);\r
+ NameSpaceSize = StrLen (String) + 1;\r
+ *NameSpace = AllocatePool (NameSpaceSize);\r
if (*NameSpace == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- UnicodeStrToAsciiStr (String, *NameSpace);\r
+ UnicodeStrToAsciiStrS (String, *NameSpace, NameSpaceSize);\r
\r
if (TmpPtr != NULL) {\r
*TmpPtr = L'&'; \r
UINTN StringSize;\r
CHAR16 *String;\r
CHAR8 *AsciiKeywordValue;\r
+ UINTN KeywordValueSize;\r
EFI_STATUS Status;\r
\r
ASSERT (StringPackage != NULL && KeywordValue != NULL && StringId != NULL);\r
//\r
// Make a ascii keyword value for later use.\r
//\r
- AsciiKeywordValue = AllocatePool (StrLen (KeywordValue) + 1);\r
+ KeywordValueSize = StrLen (KeywordValue) + 1;\r
+ AsciiKeywordValue = AllocatePool (KeywordValueSize);\r
if (AsciiKeywordValue == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- UnicodeStrToAsciiStr(KeywordValue, AsciiKeywordValue);\r
+ UnicodeStrToAsciiStrS (KeywordValue, AsciiKeywordValue, KeywordValueSize);\r
\r
while (*BlockHdr != EFI_HII_SIBT_END) {\r
switch (*BlockHdr) {\r
StringTextPtr = BlockHdr + Offset;\r
\r
if (FindString) {\r
- *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16));\r
+ StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr);\r
+ *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16));\r
if (*KeywordValue == NULL) {\r
return 0;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize);\r
return CurrentStringId;\r
} else if (CurrentStringId == StringId) {\r
FindString = TRUE;\r
StringTextPtr = BlockHdr + Offset;\r
\r
if (FindString) {\r
- *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16));\r
+ StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr);\r
+ *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16));\r
if (*KeywordValue == NULL) {\r
return 0;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize);\r
return CurrentStringId;\r
} else if (CurrentStringId == StringId) {\r
FindString = TRUE;\r
\r
for (Index = 0; Index < StringCount; Index++) {\r
if (FindString) {\r
- *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16));\r
+ StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr);\r
+ *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16));\r
if (*KeywordValue == NULL) {\r
return 0;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize);\r
return CurrentStringId;\r
} else if (CurrentStringId == StringId) {\r
FindString = TRUE;\r
\r
for (Index = 0; Index < StringCount; Index++) {\r
if (FindString) {\r
- *KeywordValue = AllocatePool (AsciiStrSize ((CHAR8 *) StringTextPtr) * sizeof (CHAR16));\r
+ StringSize = AsciiStrSize ((CHAR8 *) StringTextPtr);\r
+ *KeywordValue = AllocatePool (StringSize * sizeof (CHAR16));\r
if (*KeywordValue == NULL) {\r
return 0;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) StringTextPtr, *KeywordValue);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) StringTextPtr, *KeywordValue, StringSize);\r
return CurrentStringId;\r
} else if (CurrentStringId == StringId) {\r
FindString = TRUE;\r
UINT8 *Buffer;\r
CHAR16 *Name;\r
CHAR8 *AsciiName;\r
+ UINTN NameSize;\r
EFI_GUID *Guid;\r
UINTN MaxLen;\r
\r
}\r
\r
if (AsciiName != NULL) {\r
- Name = AllocateZeroPool (AsciiStrSize (AsciiName) * 2);\r
+ NameSize = AsciiStrSize (AsciiName);\r
+ Name = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
ASSERT (Name != NULL);\r
- AsciiStrToUnicodeStr(AsciiName, Name);\r
+ AsciiStrToUnicodeStrS (AsciiName, Name, NameSize);\r
} else {\r
Name = NULL;\r
}\r
CHAR16 *RespStr;\r
CHAR16 *PathHdr;\r
CHAR16 *UnicodeNameSpace;\r
+ UINTN NameSpaceLength;\r
\r
ASSERT ((NameSpace != NULL) && (DevicePath != NULL) && (KeywordData != NULL) && (ValueStr != NULL) && (KeywordResp != NULL));\r
\r
// 1.1 NameSpaceId size.\r
// 'NAMESPACE='<String>\r
//\r
- RespStrLen = 10 + AsciiStrLen (NameSpace);\r
- UnicodeNameSpace = AllocatePool ((AsciiStrLen (NameSpace) + 1) * sizeof (CHAR16));\r
+ NameSpaceLength = AsciiStrLen (NameSpace);\r
+ RespStrLen = 10 + NameSpaceLength;\r
+ UnicodeNameSpace = AllocatePool ((NameSpaceLength + 1) * sizeof (CHAR16));\r
if (UnicodeNameSpace == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- AsciiStrToUnicodeStr(NameSpace, UnicodeNameSpace);\r
+ AsciiStrToUnicodeStrS (NameSpace, UnicodeNameSpace, NameSpaceLength + 1);\r
\r
//\r
// 1.2 PathHdr size.\r
UINTN PackageOffset;\r
EFI_IFR_OP_HEADER *IfrOpHdr;\r
CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
EFI_STRING GuidStr;\r
EFI_STRING NameStr;\r
EFI_STRING TempStr;\r
continue;\r
}\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, VarStoreName, NameSize);\r
\r
GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) &IfrEfiVarStore->Guid, 1, &GuidStr);\r
GenerateSubStr (L"NAME=", StrLen (VarStoreName) * sizeof (CHAR16), (VOID *) VarStoreName, 2, &NameStr);\r
UINTN PackageOffset;\r
EFI_IFR_OP_HEADER *IfrOpHdr;\r
CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
UINT8 *HiiFormPackage;\r
UINTN PackageSize;\r
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;\r
case EFI_IFR_VARSTORE_OP:\r
IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {\r
FindVarstore = TRUE;\r
\r
case EFI_IFR_VARSTORE_EFI_OP:\r
IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {\r
FindVarstore = TRUE;\r
IFR_DEFAULT_DATA *DefaultDataPtr;\r
IFR_BLOCK_DATA *BlockData;\r
CHAR16 *VarStoreName;\r
+ UINTN NameSize;\r
UINT16 VarWidth;\r
UINT16 VarDefaultId;\r
BOOLEAN FirstOneOfOption;\r
\r
IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {\r
//\r
break;\r
}\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName, NameSize);\r
\r
if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {\r
//\r
{\r
EFI_STATUS Status;\r
EFI_STRING VarStoreName;\r
+ UINTN NameSize;\r
UINT8 *VarStore;\r
UINTN BufferSize;\r
\r
VarStore = NULL;\r
VarStoreName = NULL;\r
*AccessProgress = Request;\r
- \r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));\r
+\r
+ NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize);\r
\r
\r
Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
{\r
EFI_STATUS Status;\r
EFI_STRING VarStoreName;\r
+ UINTN NameSize;\r
UINT8 *VarStore;\r
UINTN BufferSize;\r
UINTN BlockSize;\r
VarStore = NULL;\r
VarStoreName = NULL;\r
\r
- VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));\r
+ NameSize = AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name);\r
+ VarStoreName = AllocateZeroPool (NameSize * sizeof (CHAR16));\r
if (VarStoreName == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
- AsciiStrToUnicodeStr ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName);\r
+ AsciiStrToUnicodeStrS ((CHAR8 *) EfiVarStoreInfo->Name, VarStoreName, NameSize);\r
\r
Status = gRT->GetVariable (VarStoreName, &EfiVarStoreInfo->Guid, NULL, &BufferSize, NULL);\r
if (Status != EFI_BUFFER_TOO_SMALL) {\r