From 0be4332193d5e6beeaaf2b9d6798653ffd870bc2 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 1 Mar 2010 22:05:55 +0000 Subject: [PATCH] Fix things mentioned in #91 --- src/iodined.c | 5 ++++- src/tun.c | 4 ++-- src/user.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/iodined.c b/src/iodined.c index 84b2281..088d298 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -2416,10 +2416,13 @@ main(int argc, char **argv) goto cleanup0; } if (!skipipconfig) { - if (tun_setip(argv[0], users_get_first_ip(), netmask) != 0 || tun_setmtu(mtu) != 0) { + const char *other_ip = users_get_first_ip(); + if (tun_setip(argv[0], other_ip, netmask) != 0 || tun_setmtu(mtu) != 0) { retval = 1; + free((void*) other_ip); goto cleanup1; } + free((void*) other_ip); } if ((dnsd_fd = open_dns(port, listen_ip)) == -1) { retval = 1; diff --git a/src/tun.c b/src/tun.c index 6802850..02c85af 100644 --- a/src/tun.c +++ b/src/tun.c @@ -426,7 +426,7 @@ read_tun(int tun_fd, char *buf, size_t len) } int -tun_setip(const char *ip, const char *remoteip, int netbits) +tun_setip(const char *ip, const char *other_ip, int netbits) { char cmdline[512]; int netmask; @@ -459,7 +459,7 @@ tun_setip(const char *ip, const char *remoteip, int netbits) if_name, ip, #ifdef FREEBSD - remoteip, /* FreeBSD wants other IP as second IP */ + other_ip, /* FreeBSD wants other IP as second IP */ #else ip, #endif diff --git a/src/user.c b/src/user.c index dfe9c36..cded79f 100644 --- a/src/user.c +++ b/src/user.c @@ -90,7 +90,7 @@ users_get_first_ip() { struct in_addr ip; ip.s_addr = users[0].tun_ip; - return inet_ntoa(ip); + return strdup(inet_ntoa(ip)); } int