From: Helge Deller <deller@gmx.de>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: Sven Schnelle <svens@stackframe.org>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH 4/4] hw/display/artist.c: fix out of bounds check
Date: Sat, 1 Aug 2020 15:10:14 +0200 [thread overview]
Message-ID: <a767a5b3-c10e-9ea3-ad6f-d342ca9d5c41@gmx.de> (raw)
In-Reply-To: <767c4e05-6018-7f99-4401-cbc1480c3d28@linaro.org>
On 29.07.20 19:26, Richard Henderson wrote:
> On 7/27/20 2:46 PM, Helge Deller wrote:
>> - for (i = 0; i < pix_count; i++) {
>> + for (i = 0; i < pix_count && offset + i < buf->size; i++) {
>> artist_rop8(s, p + offset + pix_count - 1 - i,
>> (data & 1) ? (s->plane_mask >> 24) : 0);
>> data >>= 1;
>
> This doesn't look right.
>
> You're writing to "offset + pix_count - 1 - i" and yet you're checking bounds
> vs "offset + i".
>
> This could be fixed by computing the complete offset into a local variable and
> then have an inner if to avoid the write, as you do for the second loop.
>
> But it would be better to precompute the correct loop bounds.
Thanks for the feedback.
Will send out a revised version soon.
Helge
>
> r~
>
>
>> @@ -398,7 +390,9 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
>> for (i = 3; i >= 0; i--) {
>> if (!(s->image_bitmap_op & 0x20000000) ||
>> s->vram_bitmask & (1 << (28 + i))) {
>> - artist_rop8(s, p + offset + 3 - i, data8[ROP8OFF(i)]);
>> + if (offset + 3 - i < buf->size) {
>> + artist_rop8(s, p + offset + 3 - i, data8[ROP8OFF(i)]);
>> + }
>> }
>> }
>> memory_region_set_dirty(&buf->mr, offset, 3);
>> @@ -420,7 +414,7 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
>> break;
>> }
>>
>> - for (i = 0; i < pix_count; i++) {
>> + for (i = 0; i < pix_count && offset + i < buf->size; i++) {
>> mask = 1 << (pix_count - 1 - i);
>>
>> if (!(s->image_bitmap_op & 0x20000000) ||
prev parent reply other threads:[~2020-08-01 13:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 21:46 [PATCH 0/4] Various fixes for hppa architecture Helge Deller
2020-07-27 21:46 ` [PATCH 1/4] hw/hppa: Sync hppa_hardware.h file with SeaBIOS sources Helge Deller
2020-07-29 16:36 ` Richard Henderson
2020-07-29 18:21 ` Philippe Mathieu-Daudé
2020-08-01 13:11 ` Helge Deller
2020-07-27 21:46 ` [PATCH 2/4] seabios-hppa: Update to SeaBIOS hppa version 1 Helge Deller
2020-07-27 21:46 ` [PATCH 3/4] hw/hppa: Implement proper SeaBIOS version check Helge Deller
2020-07-27 21:46 ` [PATCH 4/4] hw/display/artist.c: fix out of bounds check Helge Deller
2020-07-29 17:26 ` Richard Henderson
2020-08-01 13:10 ` Helge Deller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a767a5b3-c10e-9ea3-ad6f-d342ca9d5c41@gmx.de \
--to=deller@gmx.de \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rth@twiddle.net \
--cc=svens@stackframe.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).