The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fbdev: platinumfb: replace strcpy with strscpy
@ 2026-08-17  3:18 yuebingkun
  2026-08-17 14:37 ` David Laight
  0 siblings, 1 reply; 2+ messages in thread
From: yuebingkun @ 2026-08-17  3:18 UTC (permalink / raw)
  To: Helge Deller; +Cc: linux-fbdev, dri-devel, linux-kernel, yuebingkun

strcpy() is deprecated for use on fixed-size buffers. Replace it with
strscpy() to avoid potential buffer overflow issues.

Found by checkpatch.pl:
WARNING: Prefer strscpy over strcpy

Signed-off-by: yuebingkun <yuebingkun@kylinos.cn>
---
 drivers/video/fbdev/platinumfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index a08d955d9b43..fa27a3a4f05b 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -320,7 +320,7 @@ static void platinum_init_info(struct fb_info *info,
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
 	/* Fill fix common fields */
-	strcpy(info->fix.id, "platinum");
+	strscpy(info->fix.id, "platinum", sizeof(info->fix.id));
 	info->fix.mmio_start = pinfo->platinum_regs_phys;
 	info->fix.mmio_len = 0x1000;
 	info->fix.type = FB_TYPE_PACKED_PIXELS;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fbdev: platinumfb: replace strcpy with strscpy
  2026-08-17  3:18 [PATCH] fbdev: platinumfb: replace strcpy with strscpy yuebingkun
@ 2026-08-17 14:37 ` David Laight
  0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2026-08-17 14:37 UTC (permalink / raw)
  To: yuebingkun; +Cc: Helge Deller, linux-fbdev, dri-devel, linux-kernel

On Mon, 17 Aug 2026 11:18:16 +0800
yuebingkun <yuebingkun@kylinos.cn> wrote:

> strcpy() is deprecated for use on fixed-size buffers. Replace it with
> strscpy() to avoid potential buffer overflow issues.

There is no point using strscpy() to copy quoted strings into arrays.
Indeed, if the string is too long the kernel build will fail if strcpy()
is used but strscpy() will silently truncate the strings.
So strscpy() is actually worse here.

There are plenty of places where the destination size isn't known.
Which might be worth fixing.

	David

> 
> Found by checkpatch.pl:
> WARNING: Prefer strscpy over strcpy
> 
> Signed-off-by: yuebingkun <yuebingkun@kylinos.cn>
> ---
>  drivers/video/fbdev/platinumfb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
> index a08d955d9b43..fa27a3a4f05b 100644
> --- a/drivers/video/fbdev/platinumfb.c
> +++ b/drivers/video/fbdev/platinumfb.c
> @@ -320,7 +320,7 @@ static void platinum_init_info(struct fb_info *info,
>  	fb_alloc_cmap(&info->cmap, 256, 0);
>  
>  	/* Fill fix common fields */
> -	strcpy(info->fix.id, "platinum");
> +	strscpy(info->fix.id, "platinum", sizeof(info->fix.id));
>  	info->fix.mmio_start = pinfo->platinum_regs_phys;
>  	info->fix.mmio_len = 0x1000;
>  	info->fix.type = FB_TYPE_PACKED_PIXELS;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-17 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17  3:18 [PATCH] fbdev: platinumfb: replace strcpy with strscpy yuebingkun
2026-08-17 14:37 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox