summaryrefslogtreecommitdiff
path: root/src/linux
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-12-30 06:23:03 +0000
committerChristian Pointner <equinox@anytun.org>2008-12-30 06:23:03 +0000
commit28fd39060f79afa6bdc0fe9c8018fc0b10164473 (patch)
tree05c9c10ecc37be4300cff8e1299aa0250a7e0d53 /src/linux
parentworks on OpenBSD now (but no support for UDPv6) (diff)
fixed some out of memory errors
options parser gives now a hint where the error happened added build instructions for OpenBSD to Readme
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/tun.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/linux/tun.c b/src/linux/tun.c
index da623ae..a6d0d4b 100644
--- a/src/linux/tun.c
+++ b/src/linux/tun.c
@@ -62,16 +62,12 @@ void tun_init(tun_device_t** dev, const char* dev_name, const char* dev_type, co
return;
tun_conf(*dev, dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400);
+ (*dev)->actual_name_ = NULL;
(*dev)->fd_ = open(DEFAULT_DEVICE, O_RDWR);
if((*dev)->fd_ < 0) {
log_printf(ERR, "can't open device file (%s): %m", DEFAULT_DEVICE);
- if((*dev)->local_)
- free((*dev)->local_);
- if((*dev)->remote_netmask_)
- free((*dev)->remote_netmask_);
- free(*dev);
- *dev = NULL;
+ tun_close(dev);
return;
}
@@ -88,12 +84,7 @@ void tun_init(tun_device_t** dev, const char* dev_name, const char* dev_type, co
}
else {
log_printf(ERR, "unable to recognize type of device (tun or tap)");
- if((*dev)->local_)
- free((*dev)->local_);
- if((*dev)->remote_netmask_)
- free((*dev)->remote_netmask_);
- free(*dev);
- *dev = NULL;
+ tun_close(dev);
return;
}
@@ -106,8 +97,13 @@ void tun_init(tun_device_t** dev, const char* dev_name, const char* dev_type, co
(*dev)->actual_name_ = strdup(ifr.ifr_name);
} else {
log_printf(ERR, "tun/tap device ioctl failed: %m");
- free(*dev);
- *dev = NULL;
+ tun_close(dev);
+ return;
+ }
+
+ if(!(*dev)->actual_name_) {
+ log_printf(ERR, "can't open device file: memory error");
+ tun_close(dev);
return;
}