cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet) {
CloseHandle(device_handle);
kill(reader_pid, SIGKILL);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
int device_fd = -1;
static device_type_t device_type;
-char *device;
-char *iface;
+char *device = NULL;
+char *iface = NULL;
static char ifrname[IFNAMSIZ];
static char *device_info;
if(!ioctl(device_fd, TUNSETIFF, &ifr)) {
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
- iface = ifrname;
+ if(iface) free(iface);
+ iface = xstrdup(ifrname);
} else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) {
logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
- iface = ifrname;
+ if(iface) free(iface);
+ iface = xstrdup(ifrname);
} else
#endif
{
overwrite_mac = true;
device_info = _("Linux ethertap device");
device_type = DEVICE_TYPE_ETHERTAP;
- iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ if(iface)
+ free(iface);
+ iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
}
logger(LOG_INFO, _("%s is a %s"), device, device_info);
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
cp();
CloseHandle(device_handle);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
execute_script("tinc-down", envp);
+ if(myport) free(myport);
+
for(i = 0; i < 4; i++)
free(envp[i]);
#include "xalloc.h"
int device_fd = -1;
-char *device;
-char *iface;
+char *device = NULL;
+char *iface = NULL;
static char ifrname[IFNAMSIZ];
static char *device_info;
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
}
+static void free_names() {
+ if (identname) free(identname);
+ if (netname) free(netname);
+ if (pidfilename) free(pidfilename);
+ if (logfilename) free(logfilename);
+ if (confbase) free(confbase);
+}
+
int main(int argc, char **argv)
{
program_name = argv[0];
/* Shutdown properly. */
- close_network_connections();
-
ifdebug(CONNECTIONS)
dump_device_stats();
+ close_network_connections();
+
end:
logger(LOG_NOTICE, _("Terminating"));
remove_pid(pidfilename);
#endif
- if (identname) free(identname);
- if (netname) free(netname);
- if (pidfilename) free(pidfilename);
- if (logfilename) free(logfilename);
- if (myport) free(myport);
- if (device) free(device);
- if (iface) free(iface);
- if (confbase) free(confbase);
-
EVP_cleanup();
ENGINE_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_state(0);
ERR_free_strings();
+
+ exit_configuration(&config_tree);
+ free_names();
return status;
}
close(write_fd);
unlink(device);
+
+ free(device);
+ if(iface) free(iface);
}
bool read_packet(vpn_packet_t *packet)