]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpDxe/HttpImpl.c
SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpImpl.c
index 17deceb395473e7457e2c3616c7059eea423cc56..1acbb60d10143e3e8fa5cde1d37a9ed3e70ca86d 100644 (file)
@@ -4,13 +4,7 @@
   Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -405,10 +399,22 @@ EfiHttpRequest (
       goto Error1;\r
     }\r
 \r
-    HostName   = NULL;\r
-    Status     = HttpUrlGetHostName (Url, UrlParser, &HostName);\r
+    Status = HttpUrlGetHostName (Url, UrlParser, &HostName);\r
     if (EFI_ERROR (Status)) {\r
-     goto Error1;\r
+      goto Error1;\r
+    }\r
+\r
+    if (HttpInstance->LocalAddressIsIPv6) {\r
+      HostNameSize = AsciiStrSize (HostName);\r
+\r
+      if (HostNameSize > 2 && HostName[0] == '[' && HostName[HostNameSize - 2] == ']') {\r
+        //\r
+        // HostName format is expressed as IPv6, so, remove '[' and ']'.\r
+        //\r
+        HostNameSize -= 2;\r
+        CopyMem (HostName, HostName + 1, HostNameSize - 1);\r
+        HostName[HostNameSize - 1] = '\0';\r
+      }\r
     }\r
 \r
     Status = HttpUrlGetPort (Url, UrlParser, &RemotePort);\r
@@ -1342,7 +1348,7 @@ HttpResponseWorker (
     //\r
     // Process the received the body packet.\r
     //\r
-    HttpMsg->BodyLength = MIN (Fragment.Len, (UINT32) HttpMsg->BodyLength);\r
+    HttpMsg->BodyLength = MIN ((UINTN) Fragment.Len, HttpMsg->BodyLength);\r
 \r
     CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength);\r
 \r