ati-vga: Make sure hardware cursor data is within vram

Add check to make sure we don't read past the end of vram when getting
mouse pointer image.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-ID: <2ecf42bdeb96a4206b27dc39b3ff13cc8a6190d0.1774110169.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
This commit is contained in:
BALATON Zoltan authored and Philippe Mathieu-Daudé committed 2026-03-23 17:50:50 +01:00
1 parent 28df2e5469
commit 2f1fbe6ee9
1 file changed
+6
+6
View File
@@ -150,6 +150,9 @@ static void ati_cursor_define(ATIVGAState *s)
/* FIXME handle cur_hv_offs correctly */
srcoff = s->regs.cur_offset - (s->regs.cur_hv_offs >> 16) -
(s->regs.cur_hv_offs & 0xffff) * 16;
if (srcoff + 64 * 16 > s->vga.vram_size) {
return;
}
for (int i = 0; i < 64; i++, srcoff += 16) {
data[i] = ldq_le_p(&s->vga.vram_ptr[srcoff]);
data[i + 64] = ldq_le_p(&s->vga.vram_ptr[srcoff + 8]);
@@ -204,6 +207,9 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
}
/* FIXME handle cur_hv_offs correctly */
srcoff = s->cursor_offset + (scr_y - vga->hw_cursor_y) * 16;
if (srcoff + 16 > s->vga.vram_size) {
return;
}
dp = &dp[vga->hw_cursor_x];
h = ((s->regs.crtc_h_total_disp >> 16) + 1) * 8;
abits = ldq_be_p(&vga->vram_ptr[srcoff]);