diff options
author | Maxime Ripard <maxime@cerno.tech> | 2022-11-28 09:19:37 +0100 |
---|---|---|
committer | Maxime Ripard <maxime@cerno.tech> | 2022-12-01 11:12:44 +0100 |
commit | 0f9aa074c92dd9274b811c1c3fa93736814a4b0d (patch) | |
tree | fab9466cfc7b77ed99793a90126a01393920b307 | |
parent | b99070c07b78f1d318f8625b31128f405fef0e60 (diff) | |
download | lwn-0f9aa074c92dd9274b811c1c3fa93736814a4b0d.tar.gz lwn-0f9aa074c92dd9274b811c1c3fa93736814a4b0d.zip |
drm/modes: Use strscpy() to copy command-line mode name
The mode name in struct drm_cmdline_mode can hold 32 characters at most,
which can easily get overrun. Switch to strscpy() to prevent such a
thing.
Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527354 ("Security best practices violations")
Fixes: a7ab155397dd ("drm/modes: Switch to named mode descriptors")
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20221128081938.742410-2-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
-rw-r--r-- | drivers/gpu/drm/drm_modes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 699c66e54668..be030f4a5311 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2316,7 +2316,7 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, if (ret != name_end) continue; - strcpy(cmdline_mode->name, mode->name); + strscpy(cmdline_mode->name, mode->name, sizeof(cmdline_mode->name)); cmdline_mode->pixel_clock = mode->pixel_clock_khz; cmdline_mode->xres = mode->xres; cmdline_mode->yres = mode->yres; |