}
/* 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)
{
DBG1(DBG_LIB, "failed to ioctl tundevice: %s", strerror(errno));
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->tunfd = open("/dev/net/tun", O_RDWR);