Re: [PATCH] tty: n_gsm: replace deprecated strncpy with strscpy

From: Justin Stitt
Date: Tue Mar 19 2024 - 17:00:37 EST


Hi,

On Tue, Mar 19, 2024 at 2:11 AM Maarten Brock <Maarten.Brock@xxxxxxxx> wrote:
>
> Hi Justin,
>
> > ---
> > Note: build-tested only.
>
> Really? Without warnings?
>
> > --- a/drivers/tty/n_gsm.c
> > +++ b/drivers/tty/n_gsm.c
> > @@ -4010,7 +4010,7 @@ static int gsm_create_network(struct gsm_dlci *dlci,
> > struct gsm_netconfig *nc)
> > mux_net = netdev_priv(net);
> > mux_net->dlci = dlci;
> > kref_init(&mux_net->ref);
> > - strncpy(nc->if_name, net->name, IFNAMSIZ); /* return net name */
> > + strscpy(nc->if_name, net->name); /* return net name */
>
> Where did IFNAMSIZ go?

There's a new 2-argument strscpy introduced in Commit e6584c3964f2f
("string: Allow 2-argument strscpy()"). Since the compiler can find
nc->if_name's size (which is == IFNAMSIZ) it should be A-OK to swap to
this new form.

>
> Kind regards,
> Maarten Brock
>

Thanks
Justin