From 020498bd6a5314554abebfe56e74499fce1adaed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Tue, 7 Sep 2010 13:37:26 +0000 Subject: [PATCH] Worked through the easy klockwork-issues --- src/vpn/gnunet-helper-hijack-dns.c | 4 ++-- src/vpn/gnunet-helper-vpn.c | 8 ++++++-- src/vpn/gnunet-vpn-tun.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vpn/gnunet-helper-hijack-dns.c b/src/vpn/gnunet-helper-hijack-dns.c index 671223851..cc002a8cb 100644 --- a/src/vpn/gnunet-helper-hijack-dns.c +++ b/src/vpn/gnunet-helper-hijack-dns.c @@ -30,7 +30,7 @@ int fork_and_exec(char* file, char* cmd[]) { pid_t pid = fork(); if (pid < 0) { - fprintf(stderr, "could not fork: %m\n"); + fprintf(stderr, "could not fork: %s\n", strerror(errno)); return GNUNET_SYSERR; } @@ -61,7 +61,7 @@ int main(int argc, char** argv) { struct stat s; if (stat("/sbin/iptables", &s) < 0) { - fprintf(stderr, "stat on /sbin/iptables failed: %m\n"); + fprintf(stderr, "stat on /sbin/iptables failed: %s\n", strerror(errno)); return GNUNET_SYSERR; } diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c index 00ac1b0ec..3f9bcb3d4 100644 --- a/src/vpn/gnunet-helper-vpn.c +++ b/src/vpn/gnunet-helper-vpn.c @@ -82,6 +82,7 @@ static void set_address6(char* dev, char* address, unsigned long prefix_len) { / /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr); ifr.ifr_flags |= IFF_UP | IFF_RUNNING; /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr); + close(fd); } /* }}} */ static void set_address4(char* dev, char* address, char* mask) { /* {{{ */ @@ -123,6 +124,7 @@ static void set_address4(char* dev, char* address, char* mask) { /* {{{ */ /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr); ifr.ifr_flags |= IFF_UP | IFF_RUNNING; /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr); + close(fd); } /* }}} */ void setnonblocking(int fd) {/*{{{*/ @@ -150,7 +152,7 @@ int main(int argc, char** argv) { int fd_tun = init_tun(dev); if (fd_tun < 0) { - fprintf(stderr, "Could not initialize tun-interface: %m\n"); + fprintf(stderr, "Could not initialize tun-interface: %s\n", strerror(errno)); exit(1); } @@ -270,7 +272,7 @@ outer: while(r < ntohs(hdr.size)) { int t = write(1, buf, ntohs(hdr.size) - r); if (t < 0) { - fprintf(stderr, "write-error 1: %m, written %d/%d\n", r, ntohs(hdr.size)); + fprintf(stderr, "write-error 1: %s, written %d/%d\n", strerror(errno), r, ntohs(hdr.size)); shutdown(fd_tun, SHUT_RD); shutdown(1, SHUT_WR); rea = 0; @@ -283,5 +285,7 @@ outer: } fprintf(stderr, "Quitting!\n"); + close(fd_tun); + return 0; } diff --git a/src/vpn/gnunet-vpn-tun.c b/src/vpn/gnunet-vpn-tun.c index e3854495f..ec8632f1c 100644 --- a/src/vpn/gnunet-vpn-tun.c +++ b/src/vpn/gnunet-vpn-tun.c @@ -29,7 +29,7 @@ int init_tun(char *dev) {{{ int fd, err; if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { - fprintf(stderr, "opening /dev/net/tun: %m\n"); + fprintf(stderr, "opening /dev/net/tun: %s\n", strerror(errno)); return -1; } -- 2.25.1