diff options
author | Star Zeng <star.zeng@intel.com> | 2016-06-15 13:38:03 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-07 13:59:08 +0800 |
commit | d83399e08656dc8c951caf60b7043846cb9539cd (patch) | |
tree | 98749ef2299faad5729b576d4ab3da745413146e /NetworkPkg/HttpBootDxe | |
parent | e305e4d354d725ec62b1bafc6277170def7f8375 (diff) | |
download | edk2-platforms-d83399e08656dc8c951caf60b7043846cb9539cd.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>
(cherry picked from commit b9679cd7458110573dd4614148433312b61a1e26)
Diffstat (limited to 'NetworkPkg/HttpBootDxe')
-rw-r--r-- | NetworkPkg/HttpBootDxe/HttpBootClient.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c index f0817e92e2..319fefbbbd 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -244,6 +244,7 @@ HttpBootDhcp6ExtractUriInfo ( EFI_DHCP6_PACKET_OPTION *Option;
EFI_IPv6_ADDRESS IpAddr;
CHAR8 *HostName;
+ UINTN HostNameSize;
CHAR16 *HostNameStr;
EFI_STATUS Status;
@@ -313,14 +314,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)) {
@@ -728,6 +730,7 @@ HttpBootGetBootFile ( UINTN ContentLength;
HTTP_BOOT_CACHE_CONTENT *Cache;
UINT8 *Block;
+ UINTN UrlSize;
CHAR16 *Url;
BOOLEAN IdentityMode;
UINTN ReceivedSize;
@@ -746,11 +749,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);
if (Status != EFI_NOT_FOUND) {
@@ -848,11 +852,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.
|