Commit 78dde77b authored by Xu Panda's avatar Xu Panda Committed by Greg Kroah-Hartman

staging: r8188eu: use strscpy() to instead of strncpy()

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.
Signed-off-by: default avatarXu Panda <xu.panda@zte.com.cn>
Signed-off-by: default avatarYang Yang <yang.yang29@zte.com>
Reviewed-by: default avatarDan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/202212261905476729002@zte.com.cnSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 799468fb
...@@ -3061,8 +3061,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, ...@@ -3061,8 +3061,7 @@ static int rtw_rereg_nd_name(struct net_device *dev,
char *reg_ifname; char *reg_ifname;
reg_ifname = padapter->registrypriv.if2name; reg_ifname = padapter->registrypriv.if2name;
strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); strscpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ);
rereg_priv->old_ifname[IFNAMSIZ - 1] = 0;
} }
if (wrqu->data.length > IFNAMSIZ) if (wrqu->data.length > IFNAMSIZ)
...@@ -3084,8 +3083,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, ...@@ -3084,8 +3083,7 @@ static int rtw_rereg_nd_name(struct net_device *dev,
rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode);
} }
strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); strscpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ);
rereg_priv->old_ifname[IFNAMSIZ - 1] = 0;
if (!memcmp(new_ifname, "disable%d", 9)) { if (!memcmp(new_ifname, "disable%d", 9)) {
/* free network queue for Android's timming issue */ /* free network queue for Android's timming issue */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment