From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsN2-0005a4-5A for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:53:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCsMs-0007wY-AY for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:52:59 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 28 Mar 2012 14:52:27 +0200 Message-Id: <1332939159-16434-25-git-send-email-afaerber@suse.de> In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de> References: <1332939159-16434-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH stable-0.15 24/36] console: Fix rendering of VGA underline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Markus Armbruster , kvm@suse.de, qemu-stable@nongnu.org, Bruce Rogers , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Markus Armbruster 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) Signed-off-by: Bruce Rogers Signed-off-by: Andreas F=C3=A4rber --- console.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/console.c b/console.c index 242086c..07c82b8 100644 --- a/console.c +++ b/console.c @@ -461,7 +461,7 @@ static void vga_putcharxy(DisplayState *ds, int x, in= t y, int ch, font_data =3D *font_ptr++; if (t_attrib->uline && ((i =3D=3D FONT_HEIGHT - 2) || (i =3D=3D FONT_HEIGHT = - 3))) { - font_data =3D 0xFFFF; + font_data =3D 0xFF; } ((uint32_t *)d)[0] =3D (dmask16[(font_data >> 4)] & xorcol) = ^ bgcol; ((uint32_t *)d)[1] =3D (dmask16[(font_data >> 0) & 0xf] & xo= rcol) ^ bgcol; @@ -474,7 +474,7 @@ static void vga_putcharxy(DisplayState *ds, int x, in= t y, int ch, font_data =3D *font_ptr++; if (t_attrib->uline && ((i =3D=3D FONT_HEIGHT - 2) || (i =3D=3D FONT_HEIGHT = - 3))) { - font_data =3D 0xFFFF; + font_data =3D 0xFF; } ((uint32_t *)d)[0] =3D (dmask4[(font_data >> 6)] & xorcol) ^= bgcol; ((uint32_t *)d)[1] =3D (dmask4[(font_data >> 4) & 3] & xorco= l) ^ bgcol; @@ -487,7 +487,7 @@ static void vga_putcharxy(DisplayState *ds, int x, in= t y, int ch, for(i =3D 0; i < FONT_HEIGHT; i++) { font_data =3D *font_ptr++; if (t_attrib->uline && ((i =3D=3D FONT_HEIGHT - 2) || (i =3D= =3D FONT_HEIGHT - 3))) { - font_data =3D 0xFFFF; + font_data =3D 0xFF; } ((uint32_t *)d)[0] =3D (-((font_data >> 7)) & xorcol) ^ bgco= l; ((uint32_t *)d)[1] =3D (-((font_data >> 6) & 1) & xorcol) ^ = bgcol; --=20 1.7.7