summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2016-06-15 13:38:03 +0800
committerStar Zeng <star.zeng@intel.com>2016-06-21 12:46:24 +0800
commitb9679cd7458110573dd4614148433312b61a1e26 (patch)
tree88423b27ce0fed9ba6e79168caeff6ad8f2ddbcd
parentb68ccac17c7e6340ab7b3654ea51c86ad6b4201d (diff)
downloadedk2-platforms-b9679cd7458110573dd4614148433312b61a1e26.tar.xz
NetworkPkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr
It is the follow up of 3ab41b7a325ca11a12b42f5ad1661c4b6791cb49 to replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr with UnicodeStrToAsciiStrS/AsciiStrToUnicodeStrS. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Jiaxin Wu <jiaxin.wu@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> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
-rw-r--r--NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c6
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootClient.c19
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootConfig.c2
-rw-r--r--NetworkPkg/HttpDxe/HttpImpl.c8
-rw-r--r--NetworkPkg/HttpDxe/HttpProto.c8
-rw-r--r--NetworkPkg/IScsiDxe/IScsiConfig.c88
-rw-r--r--NetworkPkg/IScsiDxe/IScsiDriver.c2
-rw-r--r--NetworkPkg/IScsiDxe/IScsiMisc.c6
8 files changed, 87 insertions, 52 deletions
diff --git a/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c b/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c
index 9bbc11490c..06eb30c091 100644
--- a/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c
+++ b/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c
@@ -271,7 +271,7 @@ CreateSpdEntry (
//
ValueStr = ShellCommandLineGetValue (ParamPackage, L"--name");
if (ValueStr != NULL) {
- UnicodeStrToAsciiStr (ValueStr, (CHAR8 *) (*Data)->Name);
+ UnicodeStrToAsciiStrS (ValueStr, (CHAR8 *) (*Data)->Name, sizeof ((*Data)->Name));
*Mask |= NAME;
}
@@ -785,7 +785,7 @@ CreateSadEntry (
(*Data)->AlgoInfo.EspAlgoInfo.EncKeyLength = EncKeyLength;
AsciiStr = AllocateZeroPool (EncKeyLength + 1);
ASSERT (AsciiStr != NULL);
- UnicodeStrToAsciiStr (ValueStr, AsciiStr);
+ UnicodeStrToAsciiStrS (ValueStr, AsciiStr, EncKeyLength + 1);
CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.EncKey, AsciiStr, EncKeyLength);
FreePool (AsciiStr);
*Mask |= ENCRYPT_KEY;
@@ -815,7 +815,7 @@ CreateSadEntry (
(*Data)->AlgoInfo.EspAlgoInfo.AuthKeyLength = AuthKeyLength;
AsciiStr = AllocateZeroPool (AuthKeyLength + 1);
ASSERT (AsciiStr != NULL);
- UnicodeStrToAsciiStr (ValueStr, AsciiStr);
+ UnicodeStrToAsciiStrS (ValueStr, AsciiStr, AuthKeyLength + 1);
CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.AuthKey, AsciiStr, AuthKeyLength);
FreePool (AsciiStr);
*Mask |= AUTH_KEY;
diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index e543d9f883..916f2375c9 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -255,6 +255,7 @@ HttpBootDhcp6ExtractUriInfo (
EFI_DHCP6_PACKET_OPTION *Option;
EFI_IPv6_ADDRESS IpAddr;
CHAR8 *HostName;
+ UINTN HostNameSize;
CHAR16 *HostNameStr;
EFI_STATUS Status;
@@ -349,14 +350,15 @@ HttpBootDhcp6ExtractUriInfo (
if (EFI_ERROR (Status)) {
return Status;
}
-
- HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof (CHAR16));
+
+ HostNameSize = AsciiStrSize (HostName);
+ HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));
if (HostNameStr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
- AsciiStrToUnicodeStr (HostName, HostNameStr);
+ AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize);
Status = HttpBootDns (Private, HostNameStr, &IpAddr);
FreePool (HostNameStr);
if (EFI_ERROR (Status)) {
@@ -752,6 +754,7 @@ HttpBootGetBootFile (
UINTN ContentLength;
HTTP_BOOT_CACHE_CONTENT *Cache;
UINT8 *Block;
+ UINTN UrlSize;
CHAR16 *Url;
BOOLEAN IdentityMode;
UINTN ReceivedSize;
@@ -770,11 +773,12 @@ HttpBootGetBootFile (
//
// First, check whether we already cached the requested Uri.
//
- Url = AllocatePool ((AsciiStrLen (Private->BootFileUri) + 1) * sizeof (CHAR16));
+ UrlSize = AsciiStrSize (Private->BootFileUri);
+ Url = AllocatePool (UrlSize * sizeof (CHAR16));
if (Url == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AsciiStrToUnicodeStr (Private->BootFileUri, Url);
+ AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
if (!HeaderOnly) {
Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
if (Status != EFI_NOT_FOUND) {
@@ -873,11 +877,6 @@ HttpBootGetBootFile (
}
RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;
RequestData->Url = Url;
- if (RequestData->Url == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ERROR_4;
- }
- AsciiStrToUnicodeStr (Private->BootFileUri, RequestData->Url);
//
// 2.3 Record the request info in a temp cache item.
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 04c2f3efd7..7ae2ff61f2 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -104,7 +104,7 @@ HttpBootAddBootOption (
//
// Update the URI node with the input boot file URI.
//
- UnicodeStrToAsciiStr (Uri, AsciiUri);
+ UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri));
Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri);
Node = AllocatePool (Length);
if (Node == NULL) {
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index ad194dbe0e..6fcb0b7c6e 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -236,6 +236,7 @@ EfiHttpRequest (
VOID *UrlParser;
EFI_STATUS Status;
CHAR8 *HostName;
+ UINTN HostNameSize;
UINT16 RemotePort;
HTTP_PROTOCOL *HttpInstance;
BOOLEAN Configure;
@@ -343,7 +344,7 @@ EfiHttpRequest (
}
- UnicodeStrToAsciiStr (Request->Url, Url);
+ UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen);
UrlParser = NULL;
Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlParser);
if (EFI_ERROR (Status)) {
@@ -443,13 +444,14 @@ EfiHttpRequest (
}
if (EFI_ERROR (Status)) {
- HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof (CHAR16));
+ HostNameSize = AsciiStrSize (HostName);
+ HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));
if (HostNameStr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error1;
}
- AsciiStrToUnicodeStr (HostName, HostNameStr);
+ AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize);
if (!HttpInstance->LocalAddressIsIPv6) {
Status = HttpDns4 (HttpInstance, HostNameStr, &HttpInstance->RemoteAddr);
} else {
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 486b20304f..6373f07215 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1,7 +1,7 @@
/** @file
Miscellaneous routines for HttpDxe driver.
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1489,6 +1489,7 @@ HttpTcpTransmit (
EFI_STATUS Status;
CHAR8 *RequestMsg;
CHAR8 *Url;
+ UINTN UrlSize;
UINTN RequestMsgSize;
ValueInItem = (HTTP_TOKEN_WRAP *) Item->Value;
@@ -1499,12 +1500,13 @@ HttpTcpTransmit (
//
// Parse the URI of the remote host.
//
- Url = AllocatePool (StrLen (ValueInItem->HttpToken->Message->Data.Request->Url) + 1);
+ UrlSize = StrLen (ValueInItem->HttpToken->Message->Data.Request->Url) + 1;
+ Url = AllocatePool (UrlSize);
if (Url == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- UnicodeStrToAsciiStr (ValueInItem->HttpToken->Message->Data.Request->Url, Url);
+ UnicodeStrToAsciiStrS (ValueInItem->HttpToken->Message->Data.Request->Url, Url, UrlSize);
//
// Create request message.
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 69a400389d..a82ce231e8 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,7 +1,7 @@
/** @file
Helper functions for configuring or getting the parameters relating to iSCSI.
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -390,7 +390,11 @@ IScsiConvertAttemptConfigDataToIfrNvData (
IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp);
}
- AsciiStrToUnicodeStr (SessionConfigData->TargetName, IfrNvData->TargetName);
+ AsciiStrToUnicodeStrS (
+ SessionConfigData->TargetName,
+ IfrNvData->TargetName,
+ sizeof (IfrNvData->TargetName) / sizeof (IfrNvData->TargetName[0])
+ );
IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);
IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);
@@ -405,16 +409,36 @@ IScsiConvertAttemptConfigDataToIfrNvData (
if (IfrNvData->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
AuthConfigData = &Attempt->AuthConfigData.CHAP;
IfrNvData->CHAPType = AuthConfigData->CHAPType;
- AsciiStrToUnicodeStr (AuthConfigData->CHAPName, IfrNvData->CHAPName);
- AsciiStrToUnicodeStr (AuthConfigData->CHAPSecret, IfrNvData->CHAPSecret);
- AsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPName, IfrNvData->ReverseCHAPName);
- AsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData->ReverseCHAPSecret);
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->CHAPName,
+ IfrNvData->CHAPName,
+ sizeof (IfrNvData->CHAPName) / sizeof (IfrNvData->CHAPName[0])
+ );
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->CHAPSecret,
+ IfrNvData->CHAPSecret,
+ sizeof (IfrNvData->CHAPSecret) / sizeof (IfrNvData->CHAPSecret[0])
+ );
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->ReverseCHAPName,
+ IfrNvData->ReverseCHAPName,
+ sizeof (IfrNvData->ReverseCHAPName) / sizeof (IfrNvData->ReverseCHAPName[0])
+ );
+ AsciiStrToUnicodeStrS (
+ AuthConfigData->ReverseCHAPSecret,
+ IfrNvData->ReverseCHAPSecret,
+ sizeof (IfrNvData->ReverseCHAPSecret) / sizeof (IfrNvData->ReverseCHAPSecret[0])
+ );
}
//
// Other parameters.
//
- AsciiStrToUnicodeStr (Attempt->AttemptName, IfrNvData->AttemptName);
+ AsciiStrToUnicodeStrS (
+ Attempt->AttemptName,
+ IfrNvData->AttemptName,
+ sizeof (IfrNvData->AttemptName) / sizeof (IfrNvData->AttemptName[0])
+ );
}
/**
@@ -603,12 +627,12 @@ IScsiConvertIfrNvDataToAttemptConfigData (
return EFI_OUT_OF_RESOURCES;
}
- AsciiStrToUnicodeStr (Attempt->AttemptName, AttemptName1);
+ AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_MAX_SIZE);
if (StrLen (AttemptName1) > ATTEMPT_NAME_SIZE) {
CopyMem (&AttemptName1[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));
}
- AsciiStrToUnicodeStr (SameNicAttempt->AttemptName, AttemptName2);
+ AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_MAX_SIZE);
if (StrLen (AttemptName2) > ATTEMPT_NAME_SIZE) {
CopyMem (&AttemptName2[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));
}
@@ -663,7 +687,7 @@ IScsiConvertIfrNvDataToAttemptConfigData (
return EFI_OUT_OF_RESOURCES;
}
- AsciiStrToUnicodeStr (Attempt->MacString, MacString);
+ AsciiStrToUnicodeStrS (Attempt->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
@@ -1087,7 +1111,7 @@ IScsiConfigUpdateAttempt (
NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
- AsciiStrToUnicodeStr (AttemptConfigData->AttemptName, AttemptName);
+ AsciiStrToUnicodeStrS (AttemptConfigData->AttemptName, AttemptName, sizeof (AttemptName) / sizeof (AttemptName[0]));
UnicodeSPrint (mPrivate->PortString, (UINTN) 128, L"Attempt %s", AttemptName);
AttemptConfigData->AttemptTitleToken = HiiSetString (
mCallbackInfo->RegisteredHandle,
@@ -1216,7 +1240,7 @@ IScsiConfigDeleteAttempts (
mPrivate->SinglePathCount--;
}
- AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);
+ AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
@@ -1730,7 +1754,7 @@ IScsiConfigProcessDefault (
MacString
);
- UnicodeStrToAsciiStr (MacString, AttemptConfigData->MacString);
+ UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, sizeof (AttemptConfigData->MacString));
AttemptConfigData->NicIndex = NicIndex;
//
@@ -1773,7 +1797,7 @@ IScsiConfigProcessDefault (
L"%d",
(UINTN) AttemptConfigData->AttemptConfigIndex
);
- UnicodeStrToAsciiStr (mPrivate->PortString, AttemptConfigData->AttemptName);
+ UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, sizeof (AttemptConfigData->AttemptName));
//
// Save the created Attempt temporarily. If user does not save the attempt
@@ -1942,7 +1966,11 @@ IScsiFormExtractConfig (
if (EFI_ERROR (Status)) {
IfrNvData->InitiatorName[0] = L'\0';
} else {
- AsciiStrToUnicodeStr (InitiatorName, IfrNvData->InitiatorName);
+ AsciiStrToUnicodeStrS (
+ InitiatorName,
+ IfrNvData->InitiatorName,
+ sizeof (IfrNvData->InitiatorName) / sizeof (IfrNvData->InitiatorName[0])
+ );
}
//
@@ -2210,7 +2238,7 @@ IScsiFormCallback (
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (QuestionId) {
case KEY_INITIATOR_NAME:
- UnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);
+ UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, IScsiName, ISCSI_NAME_MAX_SIZE);
BufferSize = AsciiStrSize (IScsiName);
Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);
@@ -2237,7 +2265,7 @@ IScsiFormCallback (
);
}
- UnicodeStrToAsciiStr (IfrNvData->AttemptName, Private->Current->AttemptName);
+ UnicodeStrToAsciiStrS (IfrNvData->AttemptName, Private->Current->AttemptName, sizeof (Private->Current->AttemptName));
IScsiConfigUpdateAttempt ();
@@ -2366,7 +2394,7 @@ IScsiFormCallback (
break;
case KEY_TARGET_IP:
- UnicodeStrToAsciiStr (IfrNvData->TargetIp, IpString);
+ UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpString));
Status = IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp);
if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode)) {
CreatePopUp (
@@ -2383,7 +2411,7 @@ IScsiFormCallback (
break;
case KEY_TARGET_NAME:
- UnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);
+ UnicodeStrToAsciiStrS (IfrNvData->TargetName, IScsiName, ISCSI_NAME_MAX_SIZE);
Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));
if (EFI_ERROR (Status)) {
CreatePopUp (
@@ -2406,7 +2434,7 @@ IScsiFormCallback (
break;
case KEY_BOOT_LUN:
- UnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);
+ UnicodeStrToAsciiStrS (IfrNvData->BootLun, LunString, sizeof (LunString));
Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
if (EFI_ERROR (Status)) {
CreatePopUp (
@@ -2433,30 +2461,34 @@ IScsiFormCallback (
break;
case KEY_CHAP_NAME:
- UnicodeStrToAsciiStr (
+ UnicodeStrToAsciiStrS (
IfrNvData->CHAPName,
- Private->Current->AuthConfigData.CHAP.CHAPName
+ Private->Current->AuthConfigData.CHAP.CHAPName,
+ sizeof (Private->Current->AuthConfigData.CHAP.CHAPName)
);
break;
case KEY_CHAP_SECRET:
- UnicodeStrToAsciiStr (
+ UnicodeStrToAsciiStrS (
IfrNvData->CHAPSecret,
- Private->Current->AuthConfigData.CHAP.CHAPSecret
+ Private->Current->AuthConfigData.CHAP.CHAPSecret,
+ sizeof (Private->Current->AuthConfigData.CHAP.CHAPSecret)
);
break;
case KEY_REVERSE_CHAP_NAME:
- UnicodeStrToAsciiStr (
+ UnicodeStrToAsciiStrS (
IfrNvData->ReverseCHAPName,
- Private->Current->AuthConfigData.CHAP.ReverseCHAPName
+ Private->Current->AuthConfigData.CHAP.ReverseCHAPName,
+ sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPName)
);
break;
case KEY_REVERSE_CHAP_SECRET:
- UnicodeStrToAsciiStr (
+ UnicodeStrToAsciiStrS (
IfrNvData->ReverseCHAPSecret,
- Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret
+ Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret,
+ sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret)
);
break;
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 5a121ce9b3..7e7eb39ee2 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -671,7 +671,7 @@ IScsiStart (
Session->ConfigData = AttemptConfigData;
Session->AuthType = AttemptConfigData->AuthenticationType;
- AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);
+ AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index a1f2672f37..93c0d0c672 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1106,7 +1106,7 @@ IScsiGetConfigData (
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStr (AttemptTmp->MacString, MacString);
+ AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
@@ -1145,7 +1145,7 @@ IScsiGetConfigData (
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStr (AttemptTmp->MacString, MacString);
+ AsciiStrToUnicodeStrS (AttemptTmp->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,
@@ -1236,7 +1236,7 @@ IScsiGetConfigData (
//
// Refresh the state of this attempt to NVR.
//
- AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);
+ AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));
UnicodeSPrint (
mPrivate->PortString,
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,