Skip to content

Commit

Permalink
fbdev: omapfb: use strscpy() to instead of strncpy()
Browse files Browse the repository at this point in the history
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 <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
Xu Panda authored and Helge Deller committed Dec 28, 2022
1 parent 9d8b537 commit 8d8cf16
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/video/fbdev/omap/omapfb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8d8cf16

Please sign in to comment.