diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2019-01-08 22:55:02 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-18 13:47:55 +0100 |
commit | 8a085494317cab6fef25b34521dae03c83f31eaa (patch) | |
tree | e5ac4e1818f905d58b7becd161ccdcf6ebbd4e37 /drivers/tty/vt/vc_screen.c | |
parent | a5db482640c7b926357cf984701caafa8e0f8843 (diff) | |
download | talos-op-linux-8a085494317cab6fef25b34521dae03c83f31eaa.tar.gz talos-op-linux-8a085494317cab6fef25b34521dae03c83f31eaa.zip |
vcsa: clamp header values when they don't fit
The /dev/vcsa* devices have a fixed char-sized header that stores the
screen geometry and cursor location. Let's make sure it doesn't contain
random garbage when those values exceed 255. If ever it becomes necessary
to convey larger screen info to user space then a larger header in the
not-yet-implemented /dev/vcsua* devices should be considered.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/vc_screen.c')
-rw-r--r-- | drivers/tty/vt/vc_screen.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 2384ea85ffaf..3dba60825c08 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -335,8 +335,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) if (p < HEADER_SIZE) { size_t tmp_count; - con_buf0[0] = (char)vc->vc_rows; - con_buf0[1] = (char)vc->vc_cols; + /* clamp header values if they don't fit */ + con_buf0[0] = min(vc->vc_rows, 0xFFu); + con_buf0[1] = min(vc->vc_cols, 0xFFu); getconsxy(vc, con_buf0 + 2); con_buf_start += p; |