summaryrefslogtreecommitdiff
path: root/drivers/video/console_normal.c
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2019-03-23 01:29:55 +0000
committerAnatolij Gustschin <agust@denx.de>2019-04-14 14:18:47 +0200
commit96c9bf7e2ae2ac331574cf5017a0381d184a45a8 (patch)
treefb43f147d49ce3f8cd4a13005503cea066a663cc /drivers/video/console_normal.c
parent57e7775413cfd4ada728c4e60df64895dfa37e4e (diff)
video/console: Fix DM_VIDEO font glyph array indexing
When the character to be printed on a DM_VIDEO console is from the "extended ASCII" range (0x80 - 0xff), it will be treated as a negative number, as it's declared as a signed char. This leads to negative array indicies into the glyph bitmap array, and random garbled characters. Cast the character to an unsigned type to make the index always positive and avoid an out-of-bounds access. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/video/console_normal.c')
-rw-r--r--drivers/video/console_normal.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index 2cfa510d5f..7f01ee9424 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -84,7 +84,8 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
return -EAGAIN;
for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
- uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row];
+ unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row;
+ uchar bits = video_fontdata[idx];
switch (vid_priv->bpix) {
#ifdef CONFIG_VIDEO_BPP8