[PATCH] wilc1000: replace deprecated strcpy() with strscpy()

Miguel García posted 1 patch 3 months ago
drivers/net/wireless/microchip/wilc1000/netdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] wilc1000: replace deprecated strcpy() with strscpy()
Posted by Miguel García 3 months ago
strcpy() is deprecated for NUL-terminated strings.  Replace the single
instance in wilc1000 netdev setup with strscpy(), which guarantees
NUL-termination and prevents overflow.

ndev->name is a fixed-size buffer (IFNAMSIZ, 16 bytes).

Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
---
 drivers/net/wireless/microchip/wilc1000/netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index af298021e050..8f4d11e1a2a6 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -960,7 +960,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
 
 	vif = netdev_priv(ndev);
 	ndev->ieee80211_ptr = &vif->priv.wdev;
-	strcpy(ndev->name, name);
+	strscpy(ndev->name, name, sizeof(ndev->name));
 	vif->wilc = wl;
 	vif->ndev = ndev;
 	ndev->ml_priv = vif;
-- 
2.34.1

Re: [PATCH] wilc1000: replace deprecated strcpy() with strscpy()
Posted by Alexis Lothoré 3 months ago
Hi,

On Sat Jul 5, 2025 at 3:48 PM CEST, Miguel García wrote:
> strcpy() is deprecated for NUL-terminated strings.  Replace the single
> instance in wilc1000 netdev setup with strscpy(), which guarantees
> NUL-termination and prevents overflow.
>
> ndev->name is a fixed-size buffer (IFNAMSIZ, 16 bytes).
>
> Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>

LGTM, thanks for the update

Reviewed-by: Alexis Lothoré <alexis.lothore@bootlin.com>

> ---
>  drivers/net/wireless/microchip/wilc1000/netdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
> index af298021e050..8f4d11e1a2a6 100644
> --- a/drivers/net/wireless/microchip/wilc1000/netdev.c
> +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
> @@ -960,7 +960,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
>  
>  	vif = netdev_priv(ndev);
>  	ndev->ieee80211_ptr = &vif->priv.wdev;
> -	strcpy(ndev->name, name);
> +	strscpy(ndev->name, name, sizeof(ndev->name));
>  	vif->wilc = wl;
>  	vif->ndev = ndev;
>  	ndev->ml_priv = vif;




-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH] wilc1000: replace deprecated strcpy() with strscpy()
Posted by Miguel García Román 1 month, 3 weeks ago
Gentle ping.

Just checking if anything else is needed for this patch.
Reviewed-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Thanks!

El lun, 7 jul 2025 a las 8:58, Alexis Lothoré
(<alexis.lothore@bootlin.com>) escribió:
>
> Hi,
>
> On Sat Jul 5, 2025 at 3:48 PM CEST, Miguel García wrote:
> > strcpy() is deprecated for NUL-terminated strings.  Replace the single
> > instance in wilc1000 netdev setup with strscpy(), which guarantees
> > NUL-termination and prevents overflow.
> >
> > ndev->name is a fixed-size buffer (IFNAMSIZ, 16 bytes).
> >
> > Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
>
> LGTM, thanks for the update
>
> Reviewed-by: Alexis Lothoré <alexis.lothore@bootlin.com>
>
> > ---
> >  drivers/net/wireless/microchip/wilc1000/netdev.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
> > index af298021e050..8f4d11e1a2a6 100644
> > --- a/drivers/net/wireless/microchip/wilc1000/netdev.c
> > +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
> > @@ -960,7 +960,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
> >
> >       vif = netdev_priv(ndev);
> >       ndev->ieee80211_ptr = &vif->priv.wdev;
> > -     strcpy(ndev->name, name);
> > +     strscpy(ndev->name, name, sizeof(ndev->name));
> >       vif->wilc = wl;
> >       vif->ndev = ndev;
> >       ndev->ml_priv = vif;
>
>
>
>
> --
> Alexis Lothoré, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>