Only check for utun if tun_device was given

Fixes github issue #37 hopefully.
This commit is contained in:
Erik Ekman 2020-07-03 16:48:05 +02:00
parent 814a1fd7b0
commit 07b2978326
1 changed files with 6 additions and 6 deletions

View File

@ -416,16 +416,16 @@ open_tun(const char *tun_device)
int tun_fd; int tun_fd;
char tun_name[50]; char tun_name[50];
if (tun_device != NULL) {
#ifdef DARWIN #ifdef DARWIN
if (!strncmp(tun_device, "utun", 4)) { if (!strncmp(tun_device, "utun", 4)) {
tun_fd = open_utun(tun_device); tun_fd = open_utun(tun_device);
if (tun_fd >= 0) { if (tun_fd >= 0) {
return tun_fd; return tun_fd;
}
} }
}
#endif #endif
if (tun_device != NULL) {
snprintf(tun_name, sizeof(tun_name), "/dev/%s", tun_device); snprintf(tun_name, sizeof(tun_name), "/dev/%s", tun_device);
strncpy(if_name, tun_device, sizeof(if_name)); strncpy(if_name, tun_device, sizeof(if_name));
if_name[sizeof(if_name)-1] = '\0'; if_name[sizeof(if_name)-1] = '\0';