]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg: Replace UnicodeStrToAsciiStr/AsciiStrToUnicodeStr
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootClient.c
index e543d9f883035a3adafd8ccaa865d005fce2f5e8..916f2375c98b907e33579dd12d84f181cc97dc9f 100644 (file)
@@ -255,6 +255,7 @@ HttpBootDhcp6ExtractUriInfo (
   EFI_DHCP6_PACKET_OPTION         *Option;\r
   EFI_IPv6_ADDRESS                IpAddr;\r
   CHAR8                           *HostName;\r
+  UINTN                           HostNameSize;\r
   CHAR16                          *HostNameStr;\r
   EFI_STATUS                      Status;\r
 \r
@@ -349,14 +350,15 @@ HttpBootDhcp6ExtractUriInfo (
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    \r
-    HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof (CHAR16));\r
+\r
+    HostNameSize = AsciiStrSize (HostName);\r
+    HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));\r
     if (HostNameStr == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Error;\r
     }\r
     \r
-    AsciiStrToUnicodeStr (HostName, HostNameStr);\r
+    AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize);\r
     Status = HttpBootDns (Private, HostNameStr, &IpAddr);\r
     FreePool (HostNameStr);\r
     if (EFI_ERROR (Status)) {\r
@@ -752,6 +754,7 @@ HttpBootGetBootFile (
   UINTN                      ContentLength;\r
   HTTP_BOOT_CACHE_CONTENT    *Cache;\r
   UINT8                      *Block;\r
+  UINTN                      UrlSize;\r
   CHAR16                     *Url;\r
   BOOLEAN                    IdentityMode;\r
   UINTN                      ReceivedSize;\r
@@ -770,11 +773,12 @@ HttpBootGetBootFile (
   //\r
   // First, check whether we already cached the requested Uri.\r
   //\r
-  Url = AllocatePool ((AsciiStrLen (Private->BootFileUri) + 1) * sizeof (CHAR16));\r
+  UrlSize = AsciiStrSize (Private->BootFileUri);\r
+  Url = AllocatePool (UrlSize * sizeof (CHAR16));\r
   if (Url == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  AsciiStrToUnicodeStr (Private->BootFileUri, Url);\r
+  AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);\r
   if (!HeaderOnly) {\r
     Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);\r
     if (Status != EFI_NOT_FOUND) {\r
@@ -873,11 +877,6 @@ HttpBootGetBootFile (
   }\r
   RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;\r
   RequestData->Url = Url;\r
-  if (RequestData->Url == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ERROR_4;\r
-  }\r
-  AsciiStrToUnicodeStr (Private->BootFileUri, RequestData->Url);\r
 \r
   //\r
   // 2.3 Record the request info in a temp cache item.\r