ensure zero termination of tun device name

Change-Id: I4b783c6b98ddfb30a4ca4532ef8cffa8e5f3a12f
This commit is contained in:
wbokslag 2022-07-11 14:22:27 +02:00
parent 472260475b
commit bdc9b28693
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ int tun_alloc(char *dev)
*/
ifr.ifr_flags = IFF_TUN|IFF_NO_PI;
if( *dev )
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
snprintf(ifr.ifr_name, IFNAMSIZ, "%s", dev);
if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
close(fd);