summary refs log tree commit diff stats
path: root/hw/display/cirrus_vga_rop.h
diff options
context:
space:
mode:
authorhangaohuai <hangaohuai@huawei.com>2017-03-14 14:39:19 +0800
committerGerd Hoffmann <kraxel@redhat.com>2017-03-16 08:58:15 +0100
commit215902d7b6fb50c6fc216fc74f770858278ed904 (patch)
treec8167baf32fb221b518785dd596ae53dfc815fae /hw/display/cirrus_vga_rop.h
parent1883ff34b540daacae948f493b0ba525edf5f642 (diff)
downloadfocaccia-qemu-215902d7b6fb50c6fc216fc74f770858278ed904.tar.gz
focaccia-qemu-215902d7b6fb50c6fc216fc74f770858278ed904.zip
fix :cirrus_vga fix OOB read case qemu Segmentation fault
check the validity of parameters in cirrus_bitblt_rop_fwd_transp_xxx
and cirrus_bitblt_rop_fwd_xxx to avoid the OOB read which causes qemu Segmentation fault.

After the fix, we will touch the assert in
cirrus_invalidate_region:
assert(off_cur_end >= off_cur);

Signed-off-by: fangying <fangying1@huawei.com>
Signed-off-by: hangaohuai <hangaohuai@huawei.com>
Message-id: 20170314063919.16200-1-hangaohuai@huawei.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display/cirrus_vga_rop.h')
-rw-r--r--hw/display/cirrus_vga_rop.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/display/cirrus_vga_rop.h b/hw/display/cirrus_vga_rop.h
index 0925a009fe..b7447f8733 100644
--- a/hw/display/cirrus_vga_rop.h
+++ b/hw/display/cirrus_vga_rop.h
@@ -97,6 +97,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
     uint8_t p;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
+
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
+        return;
+    }
+
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x++) {
 	    p = *dst;
@@ -143,6 +148,11 @@ glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
     uint8_t p1, p2;
     dstpitch -= bltwidth;
     srcpitch -= bltwidth;
+
+    if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
+        return;
+    }
+
     for (y = 0; y < bltheight; y++) {
         for (x = 0; x < bltwidth; x+=2) {
 	    p1 = *dst;