staging: r8188eu: use strscpy() to instead of strncpy()
PATCH 1/1 staging: r8188eu: use strscpy() to instead of strncpy()
From: Xu Panda <[email protected]>
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings.
Signed-off-by Xu Panda <[email protected]>
Signed-off-by Yang Yang <[email protected]>
--- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +2 -4
@@ -3061,8 +3061,7 @@ static int rtw_rereg_nd_name(struct net_device *dev,char *reg_ifname; reg_ifname = padapter->registrypriv.if2name; -strncpy (rereg_priv->old_ifname, reg_ifname,IFNAMSIZ ); - rereg_priv->old_ifname[IFNAMSIZ -1 ] =0 ; +strscpy (rereg_priv->old_ifname, reg_ifname,IFNAMSIZ ); }if (wrqu->data.length >IFNAMSIZ )
@@ -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); } -strncpy (rereg_priv->old_ifname, new_ifname,IFNAMSIZ ); - rereg_priv->old_ifname[IFNAMSIZ -1 ] =0 ; +strscpy (rereg_priv->old_ifname, new_ifname,IFNAMSIZ );if (!memcmp (new_ifname,"disable%d" ,9 )) {/* free network queue for Android's timming issue */
Signature · 1 line
2.15.2
Quoted 8 lines · On Mon, Dec 26, 2022 at 07:05:47PM +0800, [email protected] wrote:
From: Xu Panda <[email protected]>
The implementation of
strscpy()is more robust and safer. That's now the recommended way to copy NUL-terminated strings.Signed-off-by Xu Panda <[email protected]>Signed-off-by Yang Yang <[email protected]>---
Looks good.
Reviewed-by Dan Carpenter <[email protected]>
regards,
dan carpenter