Re: [PATCH] Input: mouse: vsxxxaa: Replace strlcat() with strscpy()
From: Kees Cook
Date: Thu Nov 12 2026 - 17:12:37 EST
On Thu, Nov 05, 2026 at 11:28:13AM +0000, David Laight wrote:
> On Tue, 3 Nov 2026 22:23:18 -0800
> Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx> wrote:
>
> > In preparation for removing the deprecated strlcat() API[1], use
> > strscpy() to initialize the mouse device name.
> >
> > The destination is zero-initialized, and the constant string fits
> > within the buffer. Since the return value is unused, this preserves
> > the existing behavior.
> >
> > Link: https://github.com/KSPP/linux/issues/370 [1]
> > Signed-off-by: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
> > ---
> > drivers/input/mouse/vsxxxaa.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
> > index 042a17fe81db..b3a0d7ff5738 100644
> > --- a/drivers/input/mouse/vsxxxaa.c
> > +++ b/drivers/input/mouse/vsxxxaa.c
> > @@ -463,8 +463,8 @@ static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv)
> >
> > mouse->dev = input_dev;
> > mouse->serio = serio;
> > - strlcat(mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
> > - sizeof(mouse->name));
> > + strscpy(mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer",
> > + sizeof(mouse->name));
>
> You might as well use the 2 argument form.
I'd agree: this is a true array, so the sizeof() can be dropped. But
it's also exactly the same binary output, so I'm fine either way:
Reviewed-by: Kees Cook <kees@xxxxxxxxxx>
And I echo the surprise over strlcat being used on an empty string. :P
--
Kees Cook