summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChuhong Yuan2019-07-31 04:01:40 +0200
committerMaxime Ripard2019-08-03 12:03:01 +0200
commit9b562437d388582f5463a4c3f60ee97a2d4d8d58 (patch)
tree1041e65119331850ae8a872449a421130c9b3536 /drivers/gpu
parentdrm/bochs: Use shadow buffer for bochs framebuffer console (diff)
downloadkernel-qcow2-linux-9b562437d388582f5463a4c3f60ee97a2d4d8d58.tar.gz
kernel-qcow2-linux-9b562437d388582f5463a4c3f60ee97a2d4d8d58.tar.xz
kernel-qcow2-linux-9b562437d388582f5463a4c3f60ee97a2d4d8d58.zip
drm/modes: Fix unterminated strncpy
strncpy(dest, src, strlen(src)) leads to unterminated dest, which is dangerous. Fix it by using strscpy. Fixes: 3aeeb13d8996 ("drm/modes: Support modes names on the command line") Signed-off-by: Chuhong Yuan <hslester96@gmail.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190731020140.3529-1-hslester96@gmail.com
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_modes.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 80fcd5dc1558..b0369e690f36 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1770,7 +1770,9 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
}
if (named_mode) {
- strncpy(mode->name, name, mode_end);
+ if (mode_end + 1 > DRM_DISPLAY_MODE_LEN)
+ return false;
+ strscpy(mode->name, name, mode_end + 1);
} else {
ret = drm_mode_parse_cmdline_res_mode(name, mode_end,
parse_extras,