Re: [PATCH] media: siano: Replace strlcat() with snprintf() in sms_ir_init()
From: David Laight
Date: Fri Nov 06 2026 - 05:28:41 EST
On Thu, 5 Nov 2026 17:44:00 -0800
Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx> wrote:
> On Thu, Nov 5, 2026 at 3:32 AM David Laight <david.laight.linux@xxxxxxxxx>
> wrote:
> >
> > On Wed, 4 Nov 2026 12:25:17 +0100
> > Alejandro Colomar <alx+linux-hardening@xxxxxxxxxx> wrote:
> >
> > > Hi Mariia,
> > >
> > > > Date: 2026-11-04 01:02:39-0800
> > > > From: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
> > > >
> > > > In preparation for removing the deprecated strlcat() API[1],
> > > > replace the strscpy() and strlcat() calls with a single snprintf()
> > > > call to construct the IR device path.
> > > >
> > > > Both the source and destination buffers have the same capacity,
> > >
> > > The line above seems irrelevant, and potentially confusing.
> > > The size of the input is not important, because since we're appending
> > > stuff after it, truncation may actually happen.
> >
> > And gcc's stupid format overflow check is going to complain.
>
> Thanks for pointing this out! I initially tested with Clang, but reproduced
> the warning with GCC. I've switched to seq_buf for v3.
That is entirely OTT.
Currently scnprintf() doesn't complain.
David
>
> >
> > David
> >
>
> Best,
> Mariia
>
>
> > >
> > > > and the return values are unused. This preserves the resulting
> > > > string, including truncation behavior.
> > > >
> > > > Link: https://github.com/KSPP/linux/issues/370 [1]
> > > > Signed-off-by: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
> > >
> > > Except for the small comment above,
> > >
> > > Reviewed-by: Alejandro Colomar <alx@xxxxxxxxxx>
> > >
> > >
> > > Cheers,
> > > Alex
> > >
> > > > ---
> > > > drivers/media/common/siano/smsir.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/media/common/siano/smsir.c
> b/drivers/media/common/siano/smsir.c
> > > > index 283770d583d5..636ff228108b 100644
> > > > --- a/drivers/media/common/siano/smsir.c
> > > > +++ b/drivers/media/common/siano/smsir.c
> > > > @@ -55,8 +55,8 @@ int sms_ir_init(struct smscore_device_t *coredev)
> > > > snprintf(coredev->ir.name, sizeof(coredev->ir.name),
> > > > "SMS IR (%s)", sms_get_board(board_id)->name);
> > > >
> > > > - strscpy(coredev->ir.phys, coredev->devpath,
> sizeof(coredev->ir.phys));
> > > > - strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
> > > > + snprintf(coredev->ir.phys, sizeof(coredev->ir.phys),
> > > > + "%s/ir0", coredev->devpath);
> > > >
> > > > dev->device_name = coredev->ir.name;
> > > > dev->input_phys = coredev->ir.phys;
> > > > --
> > > > 2.43.0
> > > >
> > > >
> > >
> >