]> git.proxmox.com Git - mirror_qemu.git/commitdiff
cirrus_vga: fix potential memory overflow
authorlu zhipeng <luzhipeng@cestc.cn>
Thu, 29 Sep 2022 12:23:52 +0000 (20:23 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 12 Oct 2022 09:00:55 +0000 (11:00 +0200)
Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
Message-Id: <20220929122352.1891-1-luzhipeng@cestc.cn>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/display/cirrus_vga.c

index 3bb6a58698c142b888fa47e7ab0965f41925577f..2577005d03ce7e72fc766f4b133df72227321d34 100644 (file)
@@ -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;