* [PATCH] staging: atomisp: replace sprintf with strscpy
[not found] <20260225204548.168092-1-tomasz.unger.ref@yahoo.pl>
@ 2026-02-25 20:45 ` tomasz.unger
2026-02-26 7:10 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: tomasz.unger @ 2026-02-25 20:45 UTC (permalink / raw)
To: Hans de Goede, Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Sakari Ailus, Andy Shevchenko, linux-media,
linux-staging, linux-kernel, Tomasz Unger
From: Tomasz Unger <tomasz.unger@yahoo.pl>
Replace deprecated sprintf() with strscpy() which is the preferred
kernel API for string copying. strscpy() is safer as it guarantees
null-termination and prevents potential buffer overflows.
Since sd->name is a fixed-size array, the destination buffer size
is deduced automatically by the kernel-defined strscpy() macro,
so no explicit size parameter is needed.
Compiled and tested by loading atomisp.ko module successfully.
Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
---
drivers/staging/media/atomisp/pci/atomisp_subdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
index 3d56ca83ecb7..cef44ec9ebde 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
@@ -808,7 +808,7 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd)
int ret;
v4l2_subdev_init(sd, &isp_subdev_v4l2_ops);
- sprintf(sd->name, "Atom ISP");
+ strscpy(sd->name, "Atom ISP");
v4l2_set_subdevdata(sd, asd);
sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: atomisp: replace sprintf with strscpy
2026-02-25 20:45 ` [PATCH] staging: atomisp: replace sprintf with strscpy tomasz.unger
@ 2026-02-26 7:10 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-02-26 7:10 UTC (permalink / raw)
To: tomasz.unger
Cc: Hans de Goede, Mauro Carvalho Chehab, Greg Kroah-Hartman,
Sakari Ailus, Andy Shevchenko, linux-media, linux-staging,
linux-kernel
On Wed, Feb 25, 2026 at 09:45:48PM +0100, tomasz.unger@yahoo.pl wrote:
> From: Tomasz Unger <tomasz.unger@yahoo.pl>
>
> Replace deprecated sprintf() with strscpy() which is the preferred
> kernel API for string copying. strscpy() is safer as it guarantees
> null-termination and prevents potential buffer overflows.
>
Technically sprintf() also guarantees NUL termination. :P
When you're writing a commit like this I want the first or second
sentence to say "This patch does not affect run-time because sd->name
is a 52 character buffer." I would prefer to avoid any talk about
"potential buffer overflows." It's the same as me claiming that I am
potentially an NBA star. Something like this:
I am doing an audit of calls to sprintf(). This code is fine
because we are copying 9 characters into a 52 character buffer.
But it would be cleaner to use strscpy() instead.
> Since sd->name is a fixed-size array, the destination buffer size
> is deduced automatically by the kernel-defined strscpy() macro,
> so no explicit size parameter is needed.
>
> Compiled and tested by loading atomisp.ko module successfully.
This information should go under the --- cut off line.
>
> Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
> ---
^^^
Here.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-26 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260225204548.168092-1-tomasz.unger.ref@yahoo.pl>
2026-02-25 20:45 ` [PATCH] staging: atomisp: replace sprintf with strscpy tomasz.unger
2026-02-26 7:10 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox