qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] cirrus_vga: fix off-by-one in blit_region_is


From: Laszlo Ersek
Subject: Re: [Qemu-devel] [PATCH v2] cirrus_vga: fix off-by-one in blit_region_is_unsafe
Date: Wed, 10 Feb 2016 17:54:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

On 02/10/16 17:17, Paolo Bonzini wrote:
> The "max" value is being compared with >=, but addr + width points to
> the first byte that will _not_ be copied.  Laszlo suggested using a
> "greater than" comparison, instead of subtracting one like it is
> already done above for the height, so that max remains always positive.
> 
> The mistake is "safe"---it will reject some blits, but will never cause
> out-of-bounds writes.
> 
> Cc: Gerd Hoffmann <address@hidden>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  hw/display/cirrus_vga.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
> index b6ce1c8..57b91a7 100644
> --- a/hw/display/cirrus_vga.c
> +++ b/hw/display/cirrus_vga.c
> @@ -276,14 +276,14 @@ static bool blit_region_is_unsafe(struct CirrusVGAState 
> *s,
>              + ((int64_t)s->cirrus_blt_height-1) * pitch;
>          int32_t max = addr
>              + s->cirrus_blt_width;
> -        if (min < 0 || max >= s->vga.vram_size) {
> +        if (min < 0 || max > s->vga.vram_size) {
>              return true;
>          }
>      } else {
>          int64_t max = addr
>              + ((int64_t)s->cirrus_blt_height-1) * pitch
>              + s->cirrus_blt_width;
> -        if (max >= s->vga.vram_size) {
> +        if (max > s->vga.vram_size) {
>              return true;
>          }
>      }
> 

Thank you for your patience. :)

Reviewed-by: Laszlo Ersek <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]