Skip to contentSkip to conversation

fbdev: use strscpy() to instead of strncpy()

PATCH Applied [email protected] 2 participants 2 messages Dec 28, 2022 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev: use strscpy() to instead of strncpy()

From: Xu Panda <[email protected]>

The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings.

---
 drivers/video/fbdev/aty/atyfb_base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/aty/atyfb_base.c +1 -2
index 0ccf5d401ecb..851c1236fddb 100644
@@ -3192,8 +3192,7 @@ static void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
 		 * which we print to the screen.
 		 */
 		id = *(u8 *)par->lcd_table;
-		strncpy(model, (char *)par->lcd_table+1, 24);
-		model[23] = 0;
+		strscpy(model, (char *)par->lcd_table+1, 24);
 
 		width = par->lcd_width = *(u16 *)(par->lcd_table+25);
 		height = par->lcd_height = *(u16 *)(par->lcd_table+27);
Signature · 1 line
2.15.2
maintainer Applied
#1 lore raw
Quoted 10 lines · On 12/28/22 02:44, [email protected] wrote:

From: Xu Panda <[email protected]>

The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings.

---
  drivers/video/fbdev/aty/atyfb_base.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

applied.
Thanks!
Helge

Quoted 15 lines
drivers/video/fbdev/aty/atyfb_base.c +1 -2
index 0ccf5d401ecb..851c1236fddb 100644
@@ -3192,8 +3192,7 @@ static void aty_init_lcd(struct atyfb_par *par, u32 bios_base)
  		 * which we print to the screen.
  		 */
  		id = *(u8 *)par->lcd_table;
-		strncpy(model, (char *)par->lcd_table+1, 24);
-		model[23] = 0;
+		strscpy(model, (char *)par->lcd_table+1, 24);
 
  		width = par->lcd_width = *(u16 *)(par->lcd_table+25);
  		height = par->lcd_height = *(u16 *)(par->lcd_table+27);