From db1372214af53fa2d0a5fa4fd534fa899f1b6ec8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 25 Nov 2011 15:06:26 +0100 Subject: [PATCH 09/11] console: Fix rendering of VGA underline RH-Author: Markus Armbruster Message-id: <1322233586-20339-1-git-send-email-armbru@redhat.com> Patchwork-id: 35449 O-Subject: [RHEL-6.3 PATCH qemu-kvm] console: Fix rendering of VGA underline Bugzilla: 757132 RH-Acked-by: Jeffrey Cody RH-Acked-by: Paul Moore RH-Acked-by: Paolo Bonzini vga_putcharxy()'s underline code sets font_data to 0xffff instead of 0xff. vga_putcharxy() then reads dmask16[0xffff >> 4] and dmask4[0xffff >> 6]. In practice, these out-of-bounds subscripts "only" put a few crap bits into the display surface. For 32 bit pixels, there's no array access. font_data's extra bits go straight into the display surface. Broken when commit 6d6f7c28 implemented underline. Spotted by Coverity. Signed-off-by: Markus Armbruster Signed-off-by: Anthony Liguori (cherry picked from commit 439229c7cb97f6c4cddd3965c3e9d2b8319fe83c) --- Bug 757132 brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=3852084 console.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Signed-off-by: Michal Novotny --- console.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/console.c b/console.c index eec4a47..1c85a48 100644 --- a/console.c +++ b/console.c @@ -459,7 +459,7 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; @@ -472,7 +472,7 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; @@ -485,7 +485,7 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, for(i = 0; i < FONT_HEIGHT; i++) { font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol; -- 1.7.7.3