[PATCH] fbdev: platinumfb: replace strcpy with strscpy

Subsystems: framebuffer layer, the rest

COLD60d

4 messages, 2 authors, 2026-08-18 · open the first message on its own page

[PATCH] fbdev: platinumfb: replace strcpy with strscpy

From: yuebingkun <hidden>
Date: 2026-08-17 03:18:24

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 <redacted>
---
 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

Re: [PATCH] fbdev: platinumfb: replace strcpy with strscpy

From: David Laight <hidden>
Date: 2026-08-17 14:38:02

On Mon, 17 Aug 2026 11:18:16 +0800
yuebingkun [off-list ref] 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
quoted hunk
Found by checkpatch.pl:
WARNING: Prefer strscpy over strcpy

Signed-off-by: yuebingkun <redacted>
---
 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;

Re: [PATCH] fbdev: platinumfb: replace strcpy with strscpy

From: yuebingkun <hidden>
Date: 2026-08-18 00:48:25

On Mon, 17 Aug 2026, David Laight wrote:
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.
Thank you for the explanation. You are right, for copying a known
string literal into a fixed-size array, strcpy() is actually safer
because the compiler can catch overflow at build time. I will drop
this patch.

---

Re: [PATCH] fbdev: platinumfb: replace strcpy with strscpy

From: yuebingkun <hidden>
Date: 2026-08-18 00:54:36

On Mon, 17 Aug 2026, David Laight wrote:
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.
Thank you for the explanation. You are right, for copying a known
string literal into a fixed-size array, strcpy() is actually safer
because the compiler can catch overflow at build time. I will drop
this patch.

---
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help