From 87490d7fa9052ca1fe1b67ba01c46611f9925ded Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 7 Sep 2010 20:22:36 +0200 Subject: [PATCH] IFNAMSIZ includes terminating 0 http://www.delorie.com/gnu/docs/glibc/libc_308.html thus reverting devname to IFNAMSIZ and making sure (*tun)->devname[IFNAMSIZ-1] = 0; Signed-off-by: Emmanuel Bretelle --- lib/tun.c | 2 +- lib/tun.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tun.c b/lib/tun.c index 0f39994..03d057c 100644 --- a/lib/tun.c +++ b/lib/tun.c @@ -688,7 +688,7 @@ int tun_new(struct tun_t **tun) } strncpy((*tun)->devname, ifr.ifr_name, IFNAMSIZ); - (*tun)->devname[IFNAMSIZ] = 0; + (*tun)->devname[IFNAMSIZ-1] = 0; ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */ return 0; diff --git a/lib/tun.h b/lib/tun.h index 714144a..7972c53 100644 --- a/lib/tun.h +++ b/lib/tun.h @@ -45,7 +45,7 @@ struct tun_t { struct in_addr netmask; int addrs; /* Number of allocated IP addresses */ int routes; /* One if we allocated an automatic route */ - char devname[IFNAMSIZ+1];/* Name of the tun device */ + char devname[IFNAMSIZ];/* Name of the tun device */ int (*cb_ind) (struct tun_t *tun, void *pack, unsigned len); };