[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/12] macfb: fix overflow of color_palette array
From: |
Laurent Vivier |
Subject: |
Re: [PATCH 03/12] macfb: fix overflow of color_palette array |
Date: |
Mon, 4 Oct 2021 10:53:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
Le 02/10/2021 à 12:59, Mark Cave-Ayland a écrit :
> 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 | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/hw/display/macfb.c b/hw/display/macfb.c
> index 815870f2fe..f4e789d0d7 100644
> --- a/hw/display/macfb.c
> +++ b/hw/display/macfb.c
> @@ -307,6 +307,9 @@ static void macfb_ctrl_write(void *opaque,
> if (s->palette_current % 3) {
> macfb_invalidate_display(s);
> }
> + if (s->palette_current >= sizeof(s->color_palette)) {
> + s->palette_current = 0;
> + }
> break;
> }
> }
>
What about "s->palette_current = (s->palette_current + 1) %
sizeof(s->color_palette)"?
Thanks,
Laurent
- Re: [PATCH 01/12] macfb: handle errors that occur during realize, (continued)
- [PATCH 02/12] macfb: fix invalid object reference in macfb_common_realize(), Mark Cave-Ayland, 2021/10/02
- [PATCH 04/12] macfb: use memory_region_init_ram() in macfb_common_realize() for the framebuffer, Mark Cave-Ayland, 2021/10/02
- [PATCH 03/12] macfb: fix overflow of color_palette array, Mark Cave-Ayland, 2021/10/02
- Re: [PATCH 03/12] macfb: fix overflow of color_palette array,
Laurent Vivier <=
- [PATCH 07/12] macfb: add qdev property to specify display type, Mark Cave-Ayland, 2021/10/02
- [PATCH 08/12] macfb: add common monitor modes supported by the MacOS toolbox ROM, Mark Cave-Ayland, 2021/10/02
- [PATCH 06/12] macfb: implement mode sense to allow display type to be detected, Mark Cave-Ayland, 2021/10/02