]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr
authorStar Zeng <star.zeng@intel.com>
Wed, 15 Jun 2016 05:35:14 +0000 (13:35 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 21 Jun 2016 04:46:24 +0000 (12:46 +0800)
It is the follow up of 3ab41b7a325ca11a12b42f5ad1661c4b6791cb49
to replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr with
UnicodeStrToAsciiStrS/AsciiStrToUnicodeStrS.

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>
MdeModulePkg/Application/UiApp/FrontPage.c
MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c

index d1372d334e20d2c5d9b8a3307b6634638e5df4ca..50e35971d9e82ab818638fceeeed1764ec3e82b0 100644 (file)
@@ -483,7 +483,7 @@ GetOptionalStringByIndex (
     *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
index da0cff7556c84f0e9e2a164637fb049f1229caa3..93f6e4e88feff456f98d6a5f0b9a1395bddd7532 100644 (file)
@@ -259,6 +259,7 @@ UiCreateLanguageMenu (
 {\r
   CHAR8                       *LangCode;\r
   CHAR8                       *Lang;\r
+  UINTN                       LangSize;\r
   CHAR8                       *CurrentLang;\r
   UINTN                       OptionCount;\r
   CHAR16                      *StringBuffer;\r
@@ -328,9 +329,10 @@ UiCreateLanguageMenu (
       }\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
index 6e156e9cc30bf3b496f8558f123b3b461fbfbfd4..d3602a5000ebe5071330e0e56744b8b2b3d221da 100644 (file)
@@ -231,7 +231,7 @@ GetEmmcModelName (
   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
index f657fb9c6e9916cc0b3c0fd96e768e7b112132b2..7c70c60a502562c158f5f5e9a9dfe4e87dece070 100644 (file)
@@ -161,7 +161,7 @@ GetSdModelName (
   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
index 4acd0fad2c4dd2f884284a6cf50d81ec5c1be4f9..ef19439a48445960a0d0a64d7d7573a3eb498dab 100644 (file)
@@ -2976,18 +2976,20 @@ NetLibStrToIp4 (
   )\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
@@ -3017,18 +3019,20 @@ NetLibStrToIp6 (
   )\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
@@ -3060,6 +3064,7 @@ NetLibStrToIp6andPrefix (
   )\r
 {\r
   CHAR8                          *Ip6Str;\r
+  UINTN                          StringSize;\r
   CHAR8                          *PrefixStr;\r
   CHAR8                          *TempStr;\r
   EFI_STATUS                     Status;\r
@@ -3069,12 +3074,13 @@ NetLibStrToIp6andPrefix (
     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
index 69a2914d560e53f20db36c2f4c0eb2045cf3b363..066ea80a47541a2e91e5b9d8e0dda78140244fb0 100644 (file)
@@ -215,7 +215,7 @@ BmGetDescriptionFromDiskInfo (
       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
@@ -225,7 +225,7 @@ BmGetDescriptionFromDiskInfo (
 \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
index 725ccc7d782afb98cd1d8e06d93252baa796d035..cab92967aa9a33031c9223de2fd6c9fb39e4f23d 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -1130,13 +1130,13 @@ CreateHiiVariableNode (
   //\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
index 5e7aca96816e4d8fce42dcbe30b86f4f84c19090..03f814119993f3f57a77e0906584d5a85392b61d 100644 (file)
@@ -178,6 +178,7 @@ ExtractNameSpace (
   )\r
 {\r
   CHAR16    *TmpPtr;\r
+  UINTN     NameSpaceSize;\r
 \r
   ASSERT (NameSpace != NULL);\r
 \r
@@ -218,11 +219,12 @@ ExtractNameSpace (
   // 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
@@ -779,6 +781,7 @@ GetStringIdFromString (
   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
@@ -794,11 +797,12 @@ GetStringIdFromString (
   //\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
@@ -1065,11 +1069,12 @@ GetNextStringId (
       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
@@ -1084,11 +1089,12 @@ GetNextStringId (
       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
@@ -1105,11 +1111,12 @@ GetNextStringId (
 \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
@@ -1132,11 +1139,12 @@ GetNextStringId (
 \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
@@ -1670,6 +1678,7 @@ ConstructConfigHdr (
   UINT8                     *Buffer;\r
   CHAR16                    *Name;\r
   CHAR8                     *AsciiName;\r
+  UINTN                     NameSize;\r
   EFI_GUID                  *Guid;\r
   UINTN                     MaxLen;\r
 \r
@@ -1699,9 +1708,10 @@ ConstructConfigHdr (
   }\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
@@ -2375,6 +2385,7 @@ GenerateKeywordResp (
   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
@@ -2385,12 +2396,13 @@ GenerateKeywordResp (
   // 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
index a704734b309bd831e83e7d28189637c4401a0200..106f25db118cc0d73be1d556d3e404e2a9171975 100644 (file)
@@ -1604,6 +1604,7 @@ GetVarStoreType (
   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
@@ -1658,12 +1659,13 @@ GetVarStoreType (
         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
@@ -1836,6 +1838,7 @@ IsThisPackageList (
   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
@@ -1880,11 +1883,12 @@ IsThisPackageList (
     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
@@ -1897,11 +1901,12 @@ IsThisPackageList (
 \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
@@ -2086,6 +2091,7 @@ ParseIfrData (
   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
@@ -2144,12 +2150,13 @@ ParseIfrData (
 \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
@@ -2185,12 +2192,13 @@ ParseIfrData (
         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
@@ -3966,6 +3974,7 @@ GetConfigRespFromEfiVarStore (
 {\r
   EFI_STATUS Status;\r
   EFI_STRING VarStoreName;\r
+  UINTN      NameSize;\r
   UINT8      *VarStore;\r
   UINTN      BufferSize;\r
 \r
@@ -3974,13 +3983,14 @@ GetConfigRespFromEfiVarStore (
   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
@@ -4041,6 +4051,7 @@ RouteConfigRespForEfiVarStore (
 {\r
   EFI_STATUS Status;\r
   EFI_STRING VarStoreName;\r
+  UINTN      NameSize;\r
   UINT8      *VarStore;\r
   UINTN      BufferSize;\r
   UINTN      BlockSize;\r
@@ -4050,12 +4061,13 @@ RouteConfigRespForEfiVarStore (
   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