fbdev: omap: use strscpy() to instead of strncpy()
Subsystems (2)
PATCH 1/1 fbdev: omap: 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.
Signed-off-by Xu Panda <[email protected]>
Signed-off-by Yang Yang <[email protected]>
--- drivers/video/fbdev/omap/omapfb_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/video/fbdev/omap/omapfb_main.c +2 -3
@@ -1447,7 +1447,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) info->fbops = &omapfb_ops; info->flags =FBINFO_FLAG_DEFAULT ; -strncpy (fix->id,MODULE_NAME ,sizeof (fix->id)); +strscpy (fix->id,MODULE_NAME ,sizeof (fix->id)); info->pseudo_palette = fbdev->pseudo_palette;
@@ -1573,8 +1573,7 @@ static int omapfb_find_ctrl(struct omapfb_device *fbdev) fbdev->ctrl =NULL ; -strncpy (name, conf->lcd.ctrl_name,sizeof (name) -1 ); - name[sizeof (name) -1 ] ='\0' ; +strscpy (name, conf->lcd.ctrl_name,sizeof (name));if (strcmp (name,"internal" ) ==0 ) { fbdev->ctrl = fbdev->int_ctrl;
Signature · 1 line
2.15.2
Quoted 10 lines · On 12/28/22 02:40, [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.Signed-off-by Xu Panda <[email protected]>Signed-off-by Yang Yang <[email protected]>--- drivers/video/fbdev/omap/omapfb_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
applied.
Thanks!
Helge
Quoted 24 lines
drivers/video/fbdev/omap/omapfb_main.c +2
-3@@ -1447,7 +1447,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) info->fbops = &omapfb_ops; info->flags =FBINFO_FLAG_DEFAULT ; -strncpy (fix->id,MODULE_NAME ,sizeof (fix->id)); +strscpy (fix->id,MODULE_NAME ,sizeof (fix->id)); info->pseudo_palette = fbdev->pseudo_palette;@@ -1573,8 +1573,7 @@ static int omapfb_find_ctrl(struct omapfb_device *fbdev) fbdev->ctrl =NULL ; -strncpy (name, conf->lcd.ctrl_name,sizeof (name) -1 ); - name[sizeof (name) -1 ] ='\0' ; +strscpy (name, conf->lcd.ctrl_name,sizeof (name));if (strcmp (name,"internal" ) ==0 ) { fbdev->ctrl = fbdev->int_ctrl;