summaryrefslogtreecommitdiff
path: root/NetworkPkg/HttpBootDxe/HttpBootClient.c
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootClient.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootClient.c19
1 files changed, 9 insertions, 10 deletions
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.