From: Benjamin Cama Date: Tue, 16 Aug 2011 22:23:25 +0000 (+0200) Subject: Better tun device name length handling. X-Git-Tag: debian/2.2.1-1fdn2~2^2^2~7 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/4344f5e9c73e2ac36b67e72a400114063f037031 Better tun device name length handling. Signed-off-by: Benjamin Cama --- diff --git a/l2tpns.c b/l2tpns.c index 8224275..9f5e901 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -611,8 +611,8 @@ static void inittun(void) LOG(0, 0, 0, "Can't set tun interface: %s\n", strerror(errno)); exit(1); } - assert(strlen(ifr.ifr_name) < sizeof(config->tundevice)); - strncpy(config->tundevice, ifr.ifr_name, sizeof(config->tundevice) - 1); + assert(strlen(ifr.ifr_name) < sizeof(config->tundevice) - 1); + strncpy(config->tundevice, ifr.ifr_name, sizeof(config->tundevice)); { // get the interface index diff --git a/l2tpns.h b/l2tpns.h index 26928d1..b9a0714 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -616,6 +616,10 @@ struct Tstats #define SET_STAT(x, y) #endif +#ifndef IFNAMSIZ +# define IFNAMSIZ 16 +#endif + typedef struct { int debug; // debugging level @@ -631,7 +635,7 @@ typedef struct int reload_config; // flag to re-read config (set by cli) int multi_read_count; // amount of packets to read per fd in processing loop - char tundevice[10]; // tun device name + char tundevice[IFNAMSIZ]; // tun device name char log_filename[128]; char l2tp_secret[64]; // L2TP shared secret