From: Andrew Cooper Subject: [PATCH 19/32] console: Avoid overrunning the dmask arrays Date: Wed, 22 Apr 2015 16:08:32 +0100 Message-ID: <1429715325-5027-19-git-send-email-andrew.cooper3@citrix.com> References: <1429715235-4759-1-git-send-email-andrew.cooper3@citrix.com> <1429715325-5027-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1429715325-5027-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel List-Id: xen-devel@lists.xenproject.org From: Kaifeng Zhu The valide range of font_data should be [0, 0xFF]. Signed-off-by: Kaifeng Zhu (defects not identified by Coverity Scan) Reviewed-by: Andrew Cooper --- console.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/console.c b/console.c index 9984d6f..d4f1ad0 100644 --- a/console.c +++ b/console.c @@ -421,7 +421,8 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, { uint8_t *d; const uint8_t *font_ptr; - unsigned int font_data, linesize, xorcol, bpp; + uint8_t font_data; + unsigned int linesize, xorcol, bpp; int i; unsigned int fgcol, bgcol; @@ -450,7 +451,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; @@ -463,7 +464,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; @@ -476,7 +477,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.10.4