]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg: Fix protocol handler service in HttpDxe.
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpImpl.c
index 77aa64a2b99668ef6b65920e6820d3c665615332..745832b9d0bc15f85d802a4e0ad9dc381f4d7099 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, 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
@@ -249,6 +249,7 @@ EfiHttpRequest (
   HTTP_TOKEN_WRAP               *Wrap;\r
   CHAR8                         *FileUrl;\r
   UINTN                         RequestMsgSize;\r
+  EFI_HANDLE                    ImageHandle;\r
 \r
   //\r
   // Initializations\r
@@ -354,6 +355,16 @@ EfiHttpRequest (
     //\r
     HttpInstance->UseHttps = IsHttpsUrl (Url);\r
 \r
+    //\r
+    // HTTP is disabled, return directly if the URI is not HTTPS.\r
+    //\r
+    if (!PcdGetBool (PcdAllowHttpConnections) && !(HttpInstance->UseHttps)) {\r
+      \r
+      DEBUG ((EFI_D_ERROR, "EfiHttpRequest: HTTP is disabled.\n"));\r
+\r
+      return EFI_ACCESS_DENIED;\r
+    }\r
+\r
     //\r
     // Check whether we need to create Tls child and open the TLS protocol.\r
     //\r
@@ -361,8 +372,14 @@ EfiHttpRequest (
       //\r
       // Use TlsSb to create Tls child and open the TLS protocol.\r
       //\r
+      if (HttpInstance->LocalAddressIsIPv6) {\r
+        ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;\r
+      } else {\r
+        ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;\r
+      }\r
+\r
       HttpInstance->TlsChildHandle = TlsCreateChild (\r
-                                       HttpInstance->Service->ImageHandle,\r
+                                       ImageHandle,\r
                                        &(HttpInstance->Tls),\r
                                        &(HttpInstance->TlsConfiguration)\r
                                        );\r
@@ -591,10 +608,12 @@ EfiHttpRequest (
 \r
   Status = HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &RequestMsgSize);\r
 \r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || NULL == RequestMsg) {\r
     goto Error3;\r
   }\r
 \r
+  ASSERT (RequestMsg != NULL);\r
+\r
   //\r
   // Every request we insert a TxToken and a response call would remove the TxToken.\r
   // In cases of PUT/POST, after an initial request-response pair, we would do a\r