Skip to content

Commit

Permalink
IFNAMSIZ includes terminating 0
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chantra authored and laf0rge committed Oct 20, 2010
1 parent 4e56c83 commit 87490d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/tun.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 87490d7

Please sign in to comment.