tun-device: Fix compiler warning
Only the second was reported by the compiler (depending on the version and similarly to the previous commit only with AddressSanitizer active). The strncpy() call for UTUN_CONTROL_NAME was simply wrong.
This commit is contained in:
@@ -432,7 +432,7 @@ static bool init_tun(private_tun_device_t *this, const char *name_tmpl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get a control identifier for the utun kernel extension */
|
/* get a control identifier for the utun kernel extension */
|
||||||
strncpy(info.ctl_name, UTUN_CONTROL_NAME, strlen(UTUN_CONTROL_NAME));
|
strncpy(info.ctl_name, UTUN_CONTROL_NAME, sizeof(info.ctl_name)-1);
|
||||||
if (ioctl(this->tunfd, CTLIOCGINFO, &info) < 0)
|
if (ioctl(this->tunfd, CTLIOCGINFO, &info) < 0)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "failed to ioctl tundevice: %s", strerror(errno));
|
DBG1(DBG_LIB, "failed to ioctl tundevice: %s", strerror(errno));
|
||||||
@@ -466,7 +466,7 @@ static bool init_tun(private_tun_device_t *this, const char *name_tmpl)
|
|||||||
|
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
strncpy(this->if_name, name_tmpl ?: "tun%d", IFNAMSIZ);
|
strncpy(this->if_name, name_tmpl ?: "tun%d", IFNAMSIZ-1);
|
||||||
this->if_name[IFNAMSIZ-1] = '\0';
|
this->if_name[IFNAMSIZ-1] = '\0';
|
||||||
|
|
||||||
this->tunfd = open("/dev/net/tun", O_RDWR);
|
this->tunfd = open("/dev/net/tun", O_RDWR);
|
||||||
|
|||||||
Reference in New Issue
Block a user