qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds


From: P J P
Subject: [Qemu-devel] [PATCH] cirrus: keep vga vram pointer within bounds
Date: Wed, 11 Oct 2017 03:06:08 +0530

From: Prasad J Pandit <address@hidden>

'dst' pointer could exceed vga vram size when writing to the
cirrus memory area; it'd lead to an OOB access issue. Add check
to avoid it.

Reported-by: Niu Guoxiang <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
---
 hw/display/cirrus_vga.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index afc290ab91..451a736262 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2047,8 +2047,11 @@ static void 
cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s,
        }
        val <<= 1;
        dst++;
+        if (dst >= s->vga.vram_ptr + s->vga.vram_size) {
+            break;
+        }
     }
-    memory_region_set_dirty(&s->vga.vram, offset, 8);
+    memory_region_set_dirty(&s->vga.vram, offset, x);
 }
 
 static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
@@ -2071,8 +2074,11 @@ static void 
cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
        }
        val <<= 1;
        dst += 2;
+        if (dst >= s->vga.vram_ptr + s->vga.vram_size) {
+            break;
+        }
     }
-    memory_region_set_dirty(&s->vga.vram, offset, 16);
+    memory_region_set_dirty(&s->vga.vram, offset, x<<1);
 }
 
 /***************************************
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]