[PATCH] cirrus_vga: fix potential memory overflow

luzhipeng posted 1 patch 1 year, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220929122352.1891-1-luzhipeng@cestc.cn
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
There is a newer version of this series
hw/display/cirrus_vga.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] cirrus_vga: fix potential memory overflow
Posted by luzhipeng 1 year, 7 months ago
From: lu zhipeng <luzhipeng@cestc.cn>

Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
---
 hw/display/cirrus_vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 3bb6a58698..2577005d03 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -834,7 +834,7 @@ static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s)
                    word alignment, so we keep them for the next line */
                 /* XXX: keep alignment to speed up transfer */
                 end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;
-                copy_count = s->cirrus_srcptr_end - end_ptr;
+                copy_count = MIN(s->cirrus_srcptr_end - end_ptr, CIRRUS_BLTBUFSIZE);
                 memmove(s->cirrus_bltbuf, end_ptr, copy_count);
                 s->cirrus_srcptr = s->cirrus_bltbuf + copy_count;
                 s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;
-- 
2.31.1
Re: [PATCH] cirrus_vga: fix potential memory overflow
Posted by Gerd Hoffmann 1 year, 6 months ago
On Thu, Sep 29, 2022 at 08:23:52PM +0800, luzhipeng wrote:
> From: lu zhipeng <luzhipeng@cestc.cn>
> 
> Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>

> -                copy_count = s->cirrus_srcptr_end - end_ptr;
> +                copy_count = MIN(s->cirrus_srcptr_end - end_ptr, CIRRUS_BLTBUFSIZE);

Added to patch queue.

thanks,
  Gerd