mirror of https://github.com/acidanthera/audk.git
NetworkPkg:Fix Network memory leak when calling GetModeData interface
Multiple network protocols have a GetModeData() interface, which may allocate memory resource in the return mode data structure. It's callers responsibility to free these buffers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19758 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b1b1d64699
commit
ce22514e48
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for Dhcp6 driver.
|
||||
|
||||
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -287,6 +287,13 @@ UpdateName (
|
|||
HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State];
|
||||
}
|
||||
|
||||
if (Dhcp6ModeData.Ia != NULL) {
|
||||
FreePool (Dhcp6ModeData.Ia);
|
||||
}
|
||||
if (Dhcp6ModeData.ClientId != NULL) {
|
||||
FreePool (Dhcp6ModeData.ClientId);
|
||||
}
|
||||
|
||||
Status = AddUnicodeString2 (
|
||||
"eng",
|
||||
gDhcp6ComponentName.SupportedLanguages,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -211,6 +211,13 @@ UpdateDns4Name (
|
|||
ModeData.DnsConfigData.LocalPort
|
||||
);
|
||||
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
|
||||
if (gDnsControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gDnsControllerNameTable);
|
||||
gDnsControllerNameTable = NULL;
|
||||
|
@ -281,6 +288,13 @@ UpdateDns6Name (
|
|||
ModeData.DnsConfigData.LocalPort
|
||||
);
|
||||
|
||||
if (ModeData.DnsCacheList != NULL) {
|
||||
FreePool (ModeData.DnsCacheList);
|
||||
}
|
||||
if (ModeData.DnsServerList != NULL) {
|
||||
FreePool (ModeData.DnsServerList);
|
||||
}
|
||||
|
||||
if (gDnsControllerNameTable != NULL) {
|
||||
FreeUnicodeStringTable (gDnsControllerNameTable);
|
||||
gDnsControllerNameTable = NULL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
DnsDxe support functions implementation.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -618,13 +618,37 @@ Dns6GetMapping (
|
|||
while (!EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {
|
||||
Udp->Poll (Udp);
|
||||
|
||||
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip6Mode, NULL, NULL)) &&
|
||||
Ip6Mode.IsConfigured) {
|
||||
if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip6Mode, NULL, NULL))) {
|
||||
if (Ip6Mode.AddressList != NULL) {
|
||||
FreePool (Ip6Mode.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6Mode.GroupTable != NULL) {
|
||||
FreePool (Ip6Mode.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.RouteTable != NULL) {
|
||||
FreePool (Ip6Mode.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.NeighborCache != NULL) {
|
||||
FreePool (Ip6Mode.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6Mode.PrefixTable != NULL) {
|
||||
FreePool (Ip6Mode.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6Mode.IcmpTypeList);
|
||||
}
|
||||
|
||||
if (Ip6Mode.IsConfigured) {
|
||||
Udp->Configure (Udp, NULL);
|
||||
return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Functions implementation related with DHCPv6 for HTTP boot driver.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
|
@ -974,8 +974,13 @@ ON_EXIT:
|
|||
Dhcp6->Configure (Dhcp6, NULL);
|
||||
} else {
|
||||
ZeroMem (&Config, sizeof (EFI_DHCP6_CONFIG_DATA));
|
||||
ZeroMem (&Mode, sizeof (EFI_DHCP6_MODE_DATA));
|
||||
Dhcp6->Configure (Dhcp6, &Config);
|
||||
if (Mode.ClientId != NULL) {
|
||||
FreePool (Mode.ClientId);
|
||||
}
|
||||
if (Mode.Ia != NULL) {
|
||||
FreePool (Mode.Ia);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Implementation of EFI_COMPONENT_NAME_PROTOCOL and
|
||||
EFI_COMPONENT_NAME2_PROTOCOL protocol.
|
||||
|
||||
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -263,6 +263,32 @@ UpdateName (
|
|||
//
|
||||
Offset = 0;
|
||||
Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (Ip6ModeData.AddressList != NULL) {
|
||||
FreePool (Ip6ModeData.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.GroupTable != NULL) {
|
||||
FreePool (Ip6ModeData.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.RouteTable != NULL) {
|
||||
FreePool (Ip6ModeData.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.NeighborCache != NULL) {
|
||||
FreePool (Ip6ModeData.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.PrefixTable != NULL) {
|
||||
FreePool (Ip6ModeData.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6ModeData.IcmpTypeList);
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) && Ip6ModeData.IsStarted) {
|
||||
Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof(Address));
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Provide IPsec Key Exchange (IKE) service general interfaces.
|
||||
|
||||
Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -328,6 +328,31 @@ IkeOpenOutputUdp (
|
|||
UdpIoFreeIo (UdpService->Output);
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (Ip6ModeData.AddressList != NULL) {
|
||||
FreePool (Ip6ModeData.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.GroupTable != NULL) {
|
||||
FreePool (Ip6ModeData.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.RouteTable != NULL) {
|
||||
FreePool (Ip6ModeData.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.NeighborCache != NULL) {
|
||||
FreePool (Ip6ModeData.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.PrefixTable != NULL) {
|
||||
FreePool (Ip6ModeData.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6ModeData.IcmpTypeList);
|
||||
}
|
||||
|
||||
//
|
||||
// Reconfigure udp6 io without remote address.
|
||||
//
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Mtftp6 support functions implementation.
|
||||
|
||||
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -319,6 +319,29 @@ Mtftp6GetMapping (
|
|||
Status = Udp6->GetModeData (Udp6, NULL, &Ip6Mode, NULL, NULL);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (Ip6Mode.AddressList != NULL) {
|
||||
FreePool (Ip6Mode.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6Mode.GroupTable != NULL) {
|
||||
FreePool (Ip6Mode.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.RouteTable != NULL) {
|
||||
FreePool (Ip6Mode.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.NeighborCache != NULL) {
|
||||
FreePool (Ip6Mode.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6Mode.PrefixTable != NULL) {
|
||||
FreePool (Ip6Mode.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6Mode.IcmpTypeList);
|
||||
}
|
||||
|
||||
if (Ip6Mode.IsConfigured) {
|
||||
//
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Misc support routines for TCP driver.
|
||||
|
||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -566,7 +566,31 @@ TcpGetRcvMss (
|
|||
} else {
|
||||
Ip6 = TcpProto->TcpService->IpIo->Ip.Ip6;
|
||||
ASSERT (Ip6 != NULL);
|
||||
Ip6->GetModeData (Ip6, &Ip6Mode, NULL, NULL);
|
||||
if (!EFI_ERROR (Ip6->GetModeData (Ip6, &Ip6Mode, NULL, NULL))) {
|
||||
if (Ip6Mode.AddressList != NULL) {
|
||||
FreePool (Ip6Mode.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6Mode.GroupTable != NULL) {
|
||||
FreePool (Ip6Mode.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.RouteTable != NULL) {
|
||||
FreePool (Ip6Mode.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.NeighborCache != NULL) {
|
||||
FreePool (Ip6Mode.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6Mode.PrefixTable != NULL) {
|
||||
FreePool (Ip6Mode.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6Mode.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6Mode.IcmpTypeList);
|
||||
}
|
||||
}
|
||||
|
||||
return (UINT16) (Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Functions implementation related with DHCPv6 for UefiPxeBc Driver.
|
||||
|
||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -2082,7 +2082,12 @@ PxeBcDhcp6Sarr (
|
|||
// to find a valid router address.
|
||||
//
|
||||
CopyMem (&Private->TmpStationIp.v6, &Mode.Ia->IaAddress[0].IpAddress, sizeof (EFI_IPv6_ADDRESS));
|
||||
|
||||
if (Mode.ClientId != NULL) {
|
||||
FreePool (Mode.ClientId);
|
||||
}
|
||||
if (Mode.Ia != NULL) {
|
||||
FreePool (Mode.Ia);
|
||||
}
|
||||
//
|
||||
// Check the selected offer whether BINL retry is needed.
|
||||
//
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Driver Binding functions implementationfor for UefiPxeBc Driver.
|
||||
|
||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
|
@ -1061,6 +1061,30 @@ PxeBcCreateIp6Children (
|
|||
|
||||
Private->Ip6MaxPacketSize = Ip6ModeData.MaxPacketSize;
|
||||
|
||||
if (Ip6ModeData.AddressList != NULL) {
|
||||
FreePool (Ip6ModeData.AddressList);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.GroupTable != NULL) {
|
||||
FreePool (Ip6ModeData.GroupTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.RouteTable != NULL) {
|
||||
FreePool (Ip6ModeData.RouteTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.NeighborCache != NULL) {
|
||||
FreePool (Ip6ModeData.NeighborCache);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.PrefixTable != NULL) {
|
||||
FreePool (Ip6ModeData.PrefixTable);
|
||||
}
|
||||
|
||||
if (Ip6ModeData.IcmpTypeList != NULL) {
|
||||
FreePool (Ip6ModeData.IcmpTypeList);
|
||||
}
|
||||
|
||||
//
|
||||
// Locate Ip6->Ip6Config and store it for set IPv6 address.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue