[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 19/32] console: Avoid overrunning the dmask arrays



From: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx>

The valide range of font_data should be [0, 0xFF].

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx>
(defects not identified by Coverity Scan)
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.