diff options
author | Star Zeng <star.zeng@intel.com> | 2016-06-15 13:38:03 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2016-06-21 12:46:24 +0800 |
commit | b9679cd7458110573dd4614148433312b61a1e26 (patch) | |
tree | 88423b27ce0fed9ba6e79168caeff6ad8f2ddbcd /NetworkPkg/HttpBootDxe | |
parent | b68ccac17c7e6340ab7b3654ea51c86ad6b4201d (diff) | |
download | edk2-b9679cd7458110573dd4614148433312b61a1e26.tar.gz edk2-b9679cd7458110573dd4614148433312b61a1e26.tar.bz2 edk2-b9679cd7458110573dd4614148433312b61a1e26.zip |
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>
Diffstat (limited to 'NetworkPkg/HttpBootDxe')
-rw-r--r-- | NetworkPkg/HttpBootDxe/HttpBootClient.c | 19 | ||||
-rw-r--r-- | NetworkPkg/HttpBootDxe/HttpBootConfig.c | 2 |
2 files changed, 10 insertions, 11 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.
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) {
|