diff --git a/src/common.c b/src/common.c index 1dcecbd..5f202da 100644 --- a/src/common.c +++ b/src/common.c @@ -230,8 +230,9 @@ do_chroot(char *newroot) if (chroot(newroot) != 0 || chdir("/") != 0) err(1, "%s", newroot); - seteuid(geteuid()); - setuid(getuid()); + if (seteuid(geteuid()) != 0 || setuid(getuid()) != 0) { + err(1, "set[e]uid()"); + } #else warnx("chroot not available"); #endif diff --git a/src/iodine.c b/src/iodine.c index f8e1e94..2951c79 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -134,7 +134,9 @@ main(int argc, char **argv) int lazymode; int selecttimeout; int hostname_maxlen; +#ifdef OPENBSD int rtable = 0; +#endif struct sockaddr_storage nameservaddr; int nameservaddr_len; int nameserv_family; @@ -208,9 +210,11 @@ main(int argc, char **argv) case 'd': device = optarg; break; +#ifdef OPENBSD case 'R': rtable = atoi(optarg); break; +#endif case 'P': strncpy(password, optarg, sizeof(password)); password[sizeof(password)-1] = 0; diff --git a/src/iodined.c b/src/iodined.c index a6ccb58..75979d9 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -1591,8 +1591,10 @@ tunnel_bind(int bind_fd, int dns_fd) /* Get sockaddr from id */ fw_query_get(id, &query); - if (!query && debug >= 2) { - fprintf(stderr, "Lost sender of id %u, dropping reply\n", (id & 0xFFFF)); + if (!query) { + if (debug >= 2) { + fprintf(stderr, "Lost sender of id %u, dropping reply\n", (id & 0xFFFF)); + } return 0; } diff --git a/src/read.c b/src/read.c index ff40382..f4ad4a8 100644 --- a/src/read.c +++ b/src/read.c @@ -115,9 +115,6 @@ readlong(char *packet, char **src, uint32_t *dst) int readdata(char *packet, char **src, char *dst, size_t len) { - if (len < 0) - return 0; - memcpy(dst, *src, len); (*src) += len; @@ -232,9 +229,6 @@ putlong(char **dst, uint32_t value) int putdata(char **dst, char *data, size_t len) { - if (len < 0) - return 0; - memcpy(*dst, data, len); (*dst) += len; diff --git a/src/tun.c b/src/tun.c index 301e08d..bc5c153 100644 --- a/src/tun.c +++ b/src/tun.c @@ -447,6 +447,7 @@ tun_setip(const char *ip, const char *other_ip, int netbits) struct in_addr addr; DWORD len; #endif + const char *display_ip; netmask = 0; for (i = 0; i < netbits; i++) { @@ -460,15 +461,16 @@ tun_setip(const char *ip, const char *other_ip, int netbits) return 1; } #ifndef WINDOWS32 +# ifdef FREEBSD + display_ip = other_ip; /* FreeBSD wants other IP as second IP */ +# else + display_ip = ip; +# endif snprintf(cmdline, sizeof(cmdline), IFCONFIGPATH "ifconfig %s %s %s netmask %s", if_name, ip, -#ifdef FREEBSD - other_ip, /* FreeBSD wants other IP as second IP */ -#else - ip, -#endif + display_ip, inet_ntoa(net)); fprintf(stderr, "Setting IP of %s to %s\n", if_name, ip);