summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-12-27 15:29:59 +0000
committerChristian Pointner <equinox@anytun.org>2008-12-27 15:29:59 +0000
commit3618c5f3d5ad3c88e5143bd699c7bd7a6771bd8f (patch)
treef2897008a792de8f52738a264fbe53d96edea2d1 /src
parentadded first version of tun device (needs furhter testing) (diff)
fixed some memory errors at tun device
Diffstat (limited to 'src')
-rw-r--r--src/linux/tun.c11
-rw-r--r--src/uanytun.c7
2 files changed, 17 insertions, 1 deletions
diff --git a/src/linux/tun.c b/src/linux/tun.c
index 005f125..c886335 100644
--- a/src/linux/tun.c
+++ b/src/linux/tun.c
@@ -116,6 +116,15 @@ void tun_close(tun_device_t** dev)
if((*dev)->fd_ > 0)
close((*dev)->fd_);
+ if((*dev)->actual_name_)
+ free((*dev)->actual_name_);
+
+ if((*dev)->local_)
+ free((*dev)->local_);
+
+ if((*dev)->remote_netmask_)
+ free((*dev)->remote_netmask_);
+
free(*dev);
*dev = NULL;
}
@@ -188,4 +197,6 @@ void tun_do_ifconfig(tun_device_t* dev)
log_printf(ERR, "Execution of ifconfig failed");
else
log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result));
+
+ free(command);
}
diff --git a/src/uanytun.c b/src/uanytun.c
index 82085b4..fca5e40 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -61,10 +61,15 @@ int main(int argc, char* argv[])
log_printf(INFO, "entering main loop");
u_int8_t buf[1600];
int len = 0;
- while(1) {
+ unsigned int cnt = 0;
+ while(cnt < 10) {
len = tun_read(dev, buf, 1600);
printf("read %d bytes from device\n", len);
+ cnt++;
}
+ tun_close(&dev);
+
+ return 0;
}