[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/13] macfb: fix overflow of color_palette array
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v3 04/13] macfb: fix overflow of color_palette array |
Date: |
Thu, 7 Oct 2021 10:33:58 +0100 |
The palette_current index counter has a maximum size of 256 * 3 to cover a full
color palette of 256 RGB entries. Linux assumes that the palette_current index
wraps back around to zero after writing 256 RGB entries so ensure that
palette_current is reset at this point to prevent data corruption within
MacfbState.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/display/macfb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/display/macfb.c b/hw/display/macfb.c
index b363bab889..39dab49026 100644
--- a/hw/display/macfb.c
+++ b/hw/display/macfb.c
@@ -303,7 +303,9 @@ static void macfb_ctrl_write(void *opaque,
s->palette_current = 0;
break;
case DAFB_LUT:
- s->color_palette[s->palette_current++] = val;
+ s->color_palette[s->palette_current] = val;
+ s->palette_current = (s->palette_current + 1) %
+ ARRAY_SIZE(s->color_palette);
if (s->palette_current % 3) {
macfb_invalidate_display(s);
}
--
2.20.1
- [PATCH v3 00/13] macfb: fixes for booting MacOS, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 01/13] macfb: handle errors that occur during realize, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 02/13] macfb: update macfb.c to use the Error API best practices, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 03/13] macfb: fix invalid object reference in macfb_common_realize(), Mark Cave-Ayland, 2021/10/07
- [PATCH v3 04/13] macfb: fix overflow of color_palette array,
Mark Cave-Ayland <=
- [PATCH v3 05/13] macfb: use memory_region_init_ram() in macfb_common_realize() for the framebuffer, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 06/13] macfb: add trace events for reading and writing the control registers, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 08/13] macfb: add qdev property to specify display type, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 07/13] macfb: implement mode sense to allow display type to be detected, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 09/13] macfb: add common monitor modes supported by the MacOS toolbox ROM, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 10/13] macfb: fix up 1-bit pixel encoding, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 11/13] macfb: fix 24-bit RGB pixel encoding, Mark Cave-Ayland, 2021/10/07
- [PATCH v3 12/13] macfb: add vertical blank interrupt, Mark Cave-Ayland, 2021/10/07