Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb-moded] Initialize ipforward_data to be completely NULL
When connecting the cellular data connection fails, sometimes random data
in the ipforward_data struct will be tried to be freed. To avoid this we set
the whole struct to be 0.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Jan 27, 2014
1 parent c114271 commit 8144269
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/usb_moded-network.c
Expand Up @@ -191,7 +191,12 @@ static int write_udhcpd_conf(struct ipforward_data *ipforward, struct mode_list_
fprintf(conffile, "option\tsubnet\t255.255.255.0\n");
if(ipforward != NULL)
{
fprintf(conffile, "opt\tdns\t%s %s\n", ipforward->dns1, ipforward->dns2);
if(!ipforward->dns1 || !ipforward->dns2)
{
log_debug("No dns info!");
}
else
fprintf(conffile, "opt\tdns\t%s %s\n", ipforward->dns1, ipforward->dns2);
fprintf(conffile, "opt\trouter\t%s\n", ip);
}

Expand Down Expand Up @@ -447,6 +452,7 @@ int usb_network_set_up_dhcpd(struct mode_list_elem *data)
if(data->nat)
{
ipforward = malloc(sizeof(struct ipforward_data));
memset(ipforward, 0, sizeof(struct ipforward_data));
#ifdef CONNMAN
if(connman_get_connection_data(ipforward))
{
Expand Down

0 comments on commit 8144269

Please sign in to comment.