mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 00:14:02 +00:00
dhcp: prevent dhcp_cleanup passing external data to heap
This commit is contained in:
parent
c7e1b35899
commit
3ff267fbed
@ -719,6 +719,8 @@ dhcp_set_struct(struct netif *netif, struct dhcp *dhcp)
|
||||
|
||||
/* clear data structure */
|
||||
memset(dhcp, 0, sizeof(struct dhcp));
|
||||
/* mark this as externally allocated */
|
||||
dhcp->flags |= DHCP_FLAG_EXTERNAL_MEM;
|
||||
/* dhcp_set_state(&dhcp, DHCP_STATE_OFF); */
|
||||
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, dhcp);
|
||||
}
|
||||
@ -734,11 +736,15 @@ dhcp_set_struct(struct netif *netif, struct dhcp *dhcp)
|
||||
*/
|
||||
void dhcp_cleanup(struct netif *netif)
|
||||
{
|
||||
struct dhcp *dhcp;
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||
|
||||
if (netif_dhcp_data(netif) != NULL) {
|
||||
mem_free(netif_dhcp_data(netif));
|
||||
dhcp = netif_dhcp_data(netif);
|
||||
if (dhcp != NULL) {
|
||||
if (!(dhcp->flags & DHCP_FLAG_EXTERNAL_MEM)) {
|
||||
mem_free(dhcp);
|
||||
}
|
||||
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ extern "C" {
|
||||
#define DHCP_BOOT_FILE_LEN 128U
|
||||
|
||||
#define DHCP_FLAG_SUBNET_MASK_GIVEN 0x01
|
||||
#define DHCP_FLAG_EXTERNAL_MEM 0x02
|
||||
|
||||
/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */
|
||||
typedef enum {
|
||||
|
Loading…
Reference in New Issue
Block a user