From 07b2978326675ce13e655e056f4a482dad86bcce Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Fri, 3 Jul 2020 16:48:05 +0200 Subject: [PATCH] Only check for utun if tun_device was given Fixes github issue #37 hopefully. --- src/tun.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tun.c b/src/tun.c index 9429cb1..732616a 100644 --- a/src/tun.c +++ b/src/tun.c @@ -416,16 +416,16 @@ open_tun(const char *tun_device) int tun_fd; char tun_name[50]; + if (tun_device != NULL) { #ifdef DARWIN - if (!strncmp(tun_device, "utun", 4)) { - tun_fd = open_utun(tun_device); - if (tun_fd >= 0) { - return tun_fd; + if (!strncmp(tun_device, "utun", 4)) { + tun_fd = open_utun(tun_device); + if (tun_fd >= 0) { + return tun_fd; + } } - } #endif - if (tun_device != NULL) { snprintf(tun_name, sizeof(tun_name), "/dev/%s", tun_device); strncpy(if_name, tun_device, sizeof(if_name)); if_name[sizeof(if_name)-1] = '\0';