Fix Coverity Scan CID 140733 (Calling strncpy with a maximum size argument of 16 bytes on destination array ifr.ifr_ifrn.ifrn_name of size 16 bytes might leave the destination string unterminated.)

This commit is contained in:
Dong Anyuan
2019-06-20 12:01:46 +09:00
parent 8fe94b2f2c
commit 88042616cd
@@ -81,7 +81,7 @@ static int tun_alloc(char *dev) {
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
if( *dev )
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)-1);
if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
close(fd);