X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fraw_socket_device.c;h=8463502d45f0286520c235e2c5ca871c31882422;hb=171810e42712c7cfcd7bcfb5fe6c35f2a935e4c6;hp=3ec8e5715474014f5706c4978b8445ee4ba51a25;hpb=38489e37f50e807e51bfd28ebb8b20396eed1447;p=tinc diff --git a/src/raw_socket_device.c b/src/raw_socket_device.c index 3ec8e571..8463502d 100644 --- a/src/raw_socket_device.c +++ b/src/raw_socket_device.c @@ -28,8 +28,6 @@ #include "device.h" #include "net.h" #include "logger.h" -#include "utils.h" -#include "route.h" #include "xalloc.h" #if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX) @@ -39,11 +37,11 @@ static bool setup_device(void) { struct ifreq ifr; struct sockaddr_ll sa; - if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) { + if(!get_config_string(lookup_config(&config_tree, "Interface"), &iface)) { iface = xstrdup("eth0"); } - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { + if(!get_config_string(lookup_config(&config_tree, "Device"), &device)) { device = xstrdup(iface); } @@ -60,6 +58,7 @@ static bool setup_device(void) { #endif strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); + ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) { close(device_fd); @@ -95,7 +94,7 @@ static void close_device(void) { } static bool read_packet(vpn_packet_t *packet) { - int inlen; + ssize_t inlen; if((inlen = read(device_fd, DATA(packet), MTU)) <= 0) { logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,