summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2016-06-15 13:35:14 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-07 13:25:07 +0800
commite305e4d354d725ec62b1bafc6277170def7f8375 (patch)
treeafc93a33327874c6b2496bdb4744d6706cc15300 /MdeModulePkg/Library
parentd31fc34c04b77f785f73c14cd632ea033f0c9dfa (diff)
downloadedk2-platforms-e305e4d354d725ec62b1bafc6277170def7f8375.tar.xz
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 <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> (cherry picked from commit b68ccac17c7e6340ab7b3654ea51c86ad6b4201d)
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c18
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c4
-rw-r--r--MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c6
3 files changed, 17 insertions, 11 deletions
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.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
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 (