summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt/vt.c
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2019-01-08 22:55:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-18 13:47:55 +0100
commit8a085494317cab6fef25b34521dae03c83f31eaa (patch)
treee5ac4e1818f905d58b7becd161ccdcf6ebbd4e37 /drivers/tty/vt/vt.c
parenta5db482640c7b926357cf984701caafa8e0f8843 (diff)
downloadlinux-stable-8a085494317cab6fef25b34521dae03c83f31eaa.tar.gz
linux-stable-8a085494317cab6fef25b34521dae03c83f31eaa.tar.bz2
linux-stable-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/vt.c')
-rw-r--r--drivers/tty/vt/vt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 41ec8e5010f3..7cfa19963316 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4607,8 +4607,9 @@ EXPORT_SYMBOL_GPL(screen_pos);
void getconsxy(struct vc_data *vc, unsigned char *p)
{
- p[0] = vc->vc_x;
- p[1] = vc->vc_y;
+ /* clamp values if they don't fit */
+ p[0] = min(vc->vc_x, 0xFFu);
+ p[1] = min(vc->vc_y, 0xFFu);
}
void putconsxy(struct vc_data *vc, unsigned char *p)