X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=NetworkPkg%2FHttpDxe%2FHttpProto.c;h=d7fe271168fe29b41eb9dbb154fdf2719371b510;hp=2e784def4c01e7f4f6927f394e644b842c2ea9e6;hb=328141fcbe6a50e57175e2edd67a7acb2e9b6ab3;hpb=12b96a93f3f4f6827242f83f108a8d9c209dc6d0 diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 2e784def4c..d7fe271168 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1,7 +1,7 @@ /** @file Miscellaneous routines for HttpDxe driver. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -642,7 +642,7 @@ HttpInitProtocol ( // Status = NetLibCreateServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, &gEfiTcp4ServiceBindingProtocolGuid, &HttpInstance->Tcp4ChildHandle ); @@ -655,7 +655,7 @@ HttpInitProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, (VOID **) &Interface, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -668,7 +668,7 @@ HttpInitProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, (VOID **) &HttpInstance->Tcp4, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); @@ -680,7 +680,7 @@ HttpInitProtocol ( HttpInstance->Service->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, (VOID **) &Interface, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); @@ -693,7 +693,7 @@ HttpInitProtocol ( // Status = NetLibCreateServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, &gEfiTcp6ServiceBindingProtocolGuid, &HttpInstance->Tcp6ChildHandle ); @@ -706,7 +706,7 @@ HttpInitProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, (VOID **) &Interface, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER ); @@ -719,7 +719,7 @@ HttpInitProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, (VOID **) &HttpInstance->Tcp6, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); @@ -732,7 +732,7 @@ HttpInitProtocol ( HttpInstance->Service->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, (VOID **) &Interface, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); @@ -756,20 +756,20 @@ ON_ERROR: gBS->CloseProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->ControllerHandle ); gBS->CloseProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle ); NetLibDestroyServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, &gEfiTcp4ServiceBindingProtocolGuid, HttpInstance->Tcp4ChildHandle ); @@ -779,7 +779,7 @@ ON_ERROR: gBS->CloseProtocol ( HttpInstance->Service->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle ); } @@ -788,20 +788,20 @@ ON_ERROR: gBS->CloseProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->ControllerHandle ); gBS->CloseProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle ); NetLibDestroyServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, &gEfiTcp6ServiceBindingProtocolGuid, HttpInstance->Tcp6ChildHandle ); @@ -811,7 +811,7 @@ ON_ERROR: gBS->CloseProtocol ( HttpInstance->Service->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle ); } @@ -864,24 +864,31 @@ HttpCleanProtocol ( NetMapClean (&HttpInstance->TxTokens); NetMapClean (&HttpInstance->RxTokens); + if (HttpInstance->TlsSb != NULL && HttpInstance->TlsChildHandle != NULL) { + // + // Destroy the TLS instance. + // + HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->TlsChildHandle); + } + if (HttpInstance->Tcp4ChildHandle != NULL) { gBS->CloseProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Service->ControllerHandle ); gBS->CloseProtocol ( HttpInstance->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle ); NetLibDestroyServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, &gEfiTcp4ServiceBindingProtocolGuid, HttpInstance->Tcp4ChildHandle ); @@ -891,7 +898,7 @@ HttpCleanProtocol ( gBS->CloseProtocol ( HttpInstance->Service->Tcp4ChildHandle, &gEfiTcp4ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip4DriverBindingHandle, HttpInstance->Handle ); } @@ -900,20 +907,20 @@ HttpCleanProtocol ( gBS->CloseProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Service->ControllerHandle ); gBS->CloseProtocol ( HttpInstance->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle ); NetLibDestroyServiceChild ( HttpInstance->Service->ControllerHandle, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, &gEfiTcp6ServiceBindingProtocolGuid, HttpInstance->Tcp6ChildHandle ); @@ -923,7 +930,7 @@ HttpCleanProtocol ( gBS->CloseProtocol ( HttpInstance->Service->Tcp6ChildHandle, &gEfiTcp6ProtocolGuid, - HttpInstance->Service->ImageHandle, + HttpInstance->Service->Ip6DriverBindingHandle, HttpInstance->Handle ); } @@ -1491,7 +1498,7 @@ HttpTransmitTcp ( Status = EFI_OUT_OF_RESOURCES; return Status; } - ((TLS_RECORD_HEADER *) Buffer)->ContentType = TLS_CONTENT_TYPE_APPLICATION_DATA; + ((TLS_RECORD_HEADER *) Buffer)->ContentType = TlsContentTypeApplicationData; ((TLS_RECORD_HEADER *) Buffer)->Version.Major = HttpInstance->TlsConfigData.Version.Major; ((TLS_RECORD_HEADER *) Buffer)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor; ((TLS_RECORD_HEADER *) Buffer)->Length = (UINT16) (TxStringLen); @@ -1869,7 +1876,7 @@ HttpTcpReceiveHeader ( // // Check whether we received end of HTTP headers. // - *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR); + *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR); }; // @@ -1989,7 +1996,9 @@ HttpTcpReceiveHeader ( // // Skip the CRLF after the HTTP headers. // - *EndofHeader = *EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR); + *EndofHeader = *EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR); + + *SizeofHeaders = *EndofHeader - *HttpHeaders; return EFI_SUCCESS; } @@ -2031,8 +2040,8 @@ HttpTcpReceiveBody ( if (HttpInstance->LocalAddressIsIPv6) { Rx6Token = &Wrap->TcpWrap.Rx6Token; - Rx6Token ->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength; - Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength; + Rx6Token ->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); + Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx6Token ->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body; Rx6Token->CompletionToken.Status = EFI_NOT_READY; @@ -2043,8 +2052,8 @@ HttpTcpReceiveBody ( } } else { Rx4Token = &Wrap->TcpWrap.Rx4Token; - Rx4Token->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength; - Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength; + Rx4Token->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); + Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength); Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body; Rx4Token->CompletionToken.Status = EFI_NOT_READY;