Replace all strncpy with strlcpy for safety

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi
2022-08-24 02:23:20 +00:00
committed by Xiang Xiao
parent 96f77cb6a6
commit e4e3208180
45 changed files with 89 additions and 107 deletions
+2 -2
View File
@@ -1009,7 +1009,7 @@ static int tun_dev_init(FAR struct tun_device_s *priv,
if (devfmt)
{
strncpy(priv->dev.d_ifname, devfmt, IFNAMSIZ);
strlcpy(priv->dev.d_ifname, devfmt, IFNAMSIZ);
}
/* Register the device with the OS so that socket IOCTLs can be performed */
@@ -1342,7 +1342,7 @@ static int tun_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
tun->free_tuns &= ~(1 << intf);
priv = filep->f_priv;
strncpy(ifr->ifr_name, priv->dev.d_ifname, IFNAMSIZ);
strlcpy(ifr->ifr_name, priv->dev.d_ifname, IFNAMSIZ);
tundev_unlock(tun);
return OK;