X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ffd_device.c;h=1325ee5a1f577c96d74f72dcc668d368e79e12f5;hb=50a665643268deb1e50f118a3dcfc3e6c0f821c5;hp=5cfe75fe3914cd66887b71e9d4db14d5b783fb93;hpb=628739fb41f3877b2da0f8fb50793a2f51ff70c4;p=tinc diff --git a/src/fd_device.c b/src/fd_device.c index 5cfe75fe..1325ee5a 100644 --- a/src/fd_device.c +++ b/src/fd_device.c @@ -1,7 +1,7 @@ /* fd_device.c -- Interaction with Android tun fd Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2016 Guus Sliepen + 2001-2021 Guus Sliepen 2009 Grzegorz Dymarek 2016-2020 Pacien TRAN-GIRARD @@ -20,9 +20,11 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "system.h" + +#ifdef HAVE_SYS_UN_H #include -#include "system.h" #include "conf.h" #include "device.h" #include "ethernet.h" @@ -83,7 +85,7 @@ static int read_fd(int socket) { if(cmsgptr->cmsg_len != CMSG_LEN(sizeof(device_fd))) { logger(DEBUG_ALWAYS, LOG_ERR, "Wrong CMSG data length: %lu, expected %lu!", - (unsigned long)cmsgptr->cmsg_len, CMSG_LEN(sizeof(device_fd))); + (unsigned long)cmsgptr->cmsg_len, (unsigned long)CMSG_LEN(sizeof(device_fd))); return -1; } @@ -114,7 +116,9 @@ end: } static struct unix_socket_addr parse_socket_addr(const char *path) { - struct sockaddr_un socket_addr; + struct sockaddr_un socket_addr = { + .sun_family = AF_UNIX, + }; size_t path_length; if(strlen(path) >= sizeof(socket_addr.sun_path)) { @@ -124,7 +128,6 @@ static struct unix_socket_addr parse_socket_addr(const char *path) { }; } - socket_addr.sun_family = AF_UNIX; strncpy(socket_addr.sun_path, path, sizeof(socket_addr.sun_path)); if(path[0] == '@') { @@ -172,6 +175,10 @@ static bool setup_device(void) { static void close_device(void) { close(device_fd); device_fd = -1; + free(iface); + iface = NULL; + free(device); + device = NULL; } static inline uint16_t get_ip_ethertype(vpn_packet_t *packet) { @@ -234,3 +241,4 @@ const devops_t fd_devops = { .read = read_packet, .write = write_packet, }; +#endif