)\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