projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
67df7fb
)
Move free()s at the end om main() to the proper destructor functions.
author
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 9 Jan 2009 11:36:06 +0000
(12:36 +0100)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 9 Jan 2009 11:36:06 +0000
(12:36 +0100)
src/bsd/device.c
patch
|
blob
|
history
src/cygwin/device.c
patch
|
blob
|
history
src/linux/device.c
patch
|
blob
|
history
src/mingw/device.c
patch
|
blob
|
history
src/net_setup.c
patch
|
blob
|
history
src/raw_socket/device.c
patch
|
blob
|
history
src/solaris/device.c
patch
|
blob
|
history
src/tincd.c
patch
|
blob
|
history
src/uml_socket/device.c
patch
|
blob
|
history
diff --git
a/src/bsd/device.c
b/src/bsd/device.c
index
01b7071
..
d79d527
100644
(file)
--- a/
src/bsd/device.c
+++ b/
src/bsd/device.c
@@
-140,6
+140,9
@@
void close_device(void) {
cp();
close(device_fd);
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet) {
}
bool read_packet(vpn_packet_t *packet) {
diff --git
a/src/cygwin/device.c
b/src/cygwin/device.c
index
acb0cfa
..
c23d02d
100644
(file)
--- a/
src/cygwin/device.c
+++ b/
src/cygwin/device.c
@@
-227,6
+227,9
@@
void close_device(void)
CloseHandle(device_handle);
kill(reader_pid, SIGKILL);
CloseHandle(device_handle);
kill(reader_pid, SIGKILL);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)
diff --git
a/src/linux/device.c
b/src/linux/device.c
index
87f72ea
..
0069f54
100644
(file)
--- a/
src/linux/device.c
+++ b/
src/linux/device.c
@@
-44,8
+44,8
@@
typedef enum device_type_t {
int device_fd = -1;
static device_type_t device_type;
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;
static char ifrname[IFNAMSIZ];
static char *device_info;
@@
-93,11
+93,13
@@
bool setup_device(void)
if(!ioctl(device_fd, TUNSETIFF, &ifr)) {
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
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);
} 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
{
} else
#endif
{
@@
-105,7
+107,9
@@
bool setup_device(void)
overwrite_mac = true;
device_info = _("Linux ethertap device");
device_type = DEVICE_TYPE_ETHERTAP;
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);
}
logger(LOG_INFO, _("%s is a %s"), device, device_info);
@@
-118,6
+122,9
@@
void close_device(void)
cp();
close(device_fd);
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)
diff --git
a/src/mingw/device.c
b/src/mingw/device.c
index
5494796
..
b13cb56
100644
(file)
--- a/
src/mingw/device.c
+++ b/
src/mingw/device.c
@@
-313,6
+313,9
@@
void close_device(void)
cp();
CloseHandle(device_handle);
cp();
CloseHandle(device_handle);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)
diff --git
a/src/net_setup.c
b/src/net_setup.c
index
f4246db
..
d6d145a
100644
(file)
--- a/
src/net_setup.c
+++ b/
src/net_setup.c
@@
-608,6
+608,8
@@
void close_network_connections(void)
execute_script("tinc-down", envp);
execute_script("tinc-down", envp);
+ if(myport) free(myport);
+
for(i = 0; i < 4; i++)
free(envp[i]);
for(i = 0; i < 4; i++)
free(envp[i]);
diff --git
a/src/raw_socket/device.c
b/src/raw_socket/device.c
index
b96f06f
..
9e306b3
100644
(file)
--- a/
src/raw_socket/device.c
+++ b/
src/raw_socket/device.c
@@
-32,8
+32,8
@@
#include "xalloc.h"
int device_fd = -1;
#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;
static char ifrname[IFNAMSIZ];
static char *device_info;
@@
-90,6
+90,9
@@
void close_device(void)
cp();
close(device_fd);
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)
diff --git
a/src/solaris/device.c
b/src/solaris/device.c
index
04a36a8
..
118dfaa
100644
(file)
--- a/
src/solaris/device.c
+++ b/
src/solaris/device.c
@@
-114,6
+114,9
@@
void close_device(void)
cp();
close(device_fd);
cp();
close(device_fd);
+
+ free(device);
+ free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)
diff --git
a/src/tincd.c
b/src/tincd.c
index
746fff4
..
c4e8fad
100644
(file)
--- a/
src/tincd.c
+++ b/
src/tincd.c
@@
-392,6
+392,14
@@
static void make_names(void)
}
}
}
}
+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];
int main(int argc, char **argv)
{
program_name = argv[0];
@@
-498,11
+506,11
@@
int main2(int argc, char **argv)
/* Shutdown properly. */
/* Shutdown properly. */
- close_network_connections();
-
ifdebug(CONNECTIONS)
dump_device_stats();
ifdebug(CONNECTIONS)
dump_device_stats();
+ close_network_connections();
+
end:
logger(LOG_NOTICE, _("Terminating"));
end:
logger(LOG_NOTICE, _("Terminating"));
@@
-510,20
+518,14
@@
end:
remove_pid(pidfilename);
#endif
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();
EVP_cleanup();
ENGINE_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_state(0);
ERR_free_strings();
+
+ exit_configuration(&config_tree);
+ free_names();
return status;
}
return status;
}
diff --git
a/src/uml_socket/device.c
b/src/uml_socket/device.c
index
f81c88f
..
92ec6c3
100644
(file)
--- a/
src/uml_socket/device.c
+++ b/
src/uml_socket/device.c
@@
-171,6
+171,9
@@
void close_device(void)
close(write_fd);
unlink(device);
close(write_fd);
unlink(device);
+
+ free(device);
+ if(iface) free(iface);
}
bool read_packet(vpn_packet_t *packet)
}
bool read_packet(vpn_packet_t *packet)