From d83399e08656dc8c951caf60b7043846cb9539cd Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Wed, 15 Jun 2016 13:38:03 +0800 Subject: NetworkPkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr It is the follow up of 3ab41b7a325ca11a12b42f5ad1661c4b6791cb49 to replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr with UnicodeStrToAsciiStrS/AsciiStrToUnicodeStrS. Cc: Jiewen Yao Cc: Siyuan Fu Cc: Jiaxin Wu Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jaben Carsey Reviewed-by: Jiaxin Wu Reviewed-by: Siyuan Fu (cherry picked from commit b9679cd7458110573dd4614148433312b61a1e26) --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'NetworkPkg/HttpBootDxe') 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. -- cgit v1.2.3