net-snk: Fix memory leak in dhcp6_process_options()
The dhcp6_process_options() function allocates a struct dhcp6_received_options each time it is called - but that struct never gets used - and especially is also never freed again. Fix this memory leak by simply removing the unused code. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
parent
c0fbf94bc5
commit
2e9f1f28d2
|
@ -130,8 +130,7 @@ dhcpv6 ( char *ret_buffer, void *fn_ip)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dhcp6_received_options *
|
static void dhcp6_process_options (uint8_t *option, int32_t option_length)
|
||||||
dhcp6_process_options (uint8_t *option, int32_t option_length)
|
|
||||||
{
|
{
|
||||||
struct dhcp_boot_url *option_boot_url;
|
struct dhcp_boot_url *option_boot_url;
|
||||||
struct client_identifier *option_clientid;
|
struct client_identifier *option_clientid;
|
||||||
|
@ -139,24 +138,19 @@ dhcp6_process_options (uint8_t *option, int32_t option_length)
|
||||||
struct dhcp_dns *option_dns;
|
struct dhcp_dns *option_dns;
|
||||||
struct dhcp_dns_list *option_dns_list;
|
struct dhcp_dns_list *option_dns_list;
|
||||||
struct dhcp6_gen_option *option_gen;
|
struct dhcp6_gen_option *option_gen;
|
||||||
struct dhcp6_received_options *received_options;
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
|
|
||||||
received_options = malloc (sizeof(struct dhcp6_received_options));
|
|
||||||
while (option_length > 0) {
|
while (option_length > 0) {
|
||||||
switch ((uint16_t) *(option+1)) {
|
switch ((uint16_t) *(option+1)) {
|
||||||
case DHCPV6_OPTION_CLIENTID:
|
case DHCPV6_OPTION_CLIENTID:
|
||||||
option_clientid = (struct client_identifier *) option;
|
option_clientid = (struct client_identifier *) option;
|
||||||
option = option + option_clientid->length + 4;
|
option = option + option_clientid->length + 4;
|
||||||
option_length = option_length - option_clientid->length - 4;
|
option_length = option_length - option_clientid->length - 4;
|
||||||
received_options->client_id = 1;
|
|
||||||
break;
|
break;
|
||||||
case DHCPV6_OPTION_SERVERID:
|
case DHCPV6_OPTION_SERVERID:
|
||||||
option_serverid = (struct server_identifier *) option;
|
option_serverid = (struct server_identifier *) option;
|
||||||
option = option + option_serverid->length + 4;
|
option = option + option_serverid->length + 4;
|
||||||
option_length = option_length - option_serverid->length - 4;
|
option_length = option_length - option_serverid->length - 4;
|
||||||
received_options->server_id = 1;
|
|
||||||
break;
|
break;
|
||||||
case DHCPV6_OPTION_DNS_SERVERS:
|
case DHCPV6_OPTION_DNS_SERVERS:
|
||||||
option_dns = (struct dhcp_dns *) option;
|
option_dns = (struct dhcp_dns *) option;
|
||||||
|
@ -185,7 +179,7 @@ dhcp6_process_options (uint8_t *option, int32_t option_length)
|
||||||
(char *)my_fn_ip->filename,
|
(char *)my_fn_ip->filename,
|
||||||
(int)my_fn_ip->fd,
|
(int)my_fn_ip->fd,
|
||||||
option_boot_url->length) == -1)
|
option_boot_url->length) == -1)
|
||||||
return NULL;
|
return;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
option_gen = (struct dhcp6_gen_option *) option;
|
option_gen = (struct dhcp6_gen_option *) option;
|
||||||
|
@ -193,8 +187,6 @@ dhcp6_process_options (uint8_t *option, int32_t option_length)
|
||||||
option_length = option_length - option_gen->length - 4;
|
option_length = option_length - option_gen->length - 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return received_options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
|
@ -144,12 +144,6 @@ struct dhcp_boot_url {
|
||||||
uint8_t url[256];
|
uint8_t url[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dhcp6_received_options {
|
|
||||||
uint8_t filename;
|
|
||||||
uint8_t ip;
|
|
||||||
uint8_t client_id;
|
|
||||||
uint8_t server_id;
|
|
||||||
};
|
|
||||||
struct dhcp_message_reply {
|
struct dhcp_message_reply {
|
||||||
uint8_t type; /* Message type */
|
uint8_t type; /* Message type */
|
||||||
uint8_t transaction_id[3]; /* Transaction id */
|
uint8_t transaction_id[3]; /* Transaction id */
|
||||||
|
|
Loading…
Reference in New Issue