From patchwork Mon Jul 27 21:46:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 11687699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A1F013B1 for ; Mon, 27 Jul 2020 21:49:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E50C12072E for ; Mon, 27 Jul 2020 21:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="dKDGM8dY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E50C12072E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0Azn-00027v-U3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jul 2020 17:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0Awu-0000Ro-IC for qemu-devel@nongnu.org; Mon, 27 Jul 2020 17:46:20 -0400 Received: from mout.gmx.net ([212.227.15.18]:55295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0Aws-0002nP-Iy for qemu-devel@nongnu.org; Mon, 27 Jul 2020 17:46:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1595886372; bh=9cHFcYkhREm/XKFlpMeM2pJowRIOAkKoOTQvH5tpvRQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dKDGM8dY17TnYWBFIJ5jvhI0Mpy+Asbev/cwafne8vJCw/WbdxgY/B0j3LsaIo0S5 KWF2iFYIfSCAxX8AhRl/eCWGCcXiEXJfNIn9h2LEhs6KpT//DIvb39IM7na/SKmRrI s6qbDhLU2usqQiMMXj8s37LGVm/aNOjSsIuFWRAc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ls3530.fritz.box ([92.116.179.161]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mplc7-1kaNlx0d0X-00qF0e; Mon, 27 Jul 2020 23:46:12 +0200 From: Helge Deller To: qemu-devel@nongnu.org Subject: [PATCH 4/4] hw/display/artist.c: fix out of bounds check Date: Mon, 27 Jul 2020 23:46:08 +0200 Message-Id: <20200727214608.32710-5-deller@gmx.de> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200727214608.32710-1-deller@gmx.de> References: <20200727214608.32710-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:lP/RZ4XX16avRDKvZJEn/6qapwKvzw49U47eULi0EvIYyUImDtl vTgXq4X45tNFseouhuJYLg65dWOospRofQ7l84p0i0nsQzr/zB9GQkjMSPRd6RE9mBiL8mA 1Vm/Kqp8ID5Lc+S1/0lcZQbwF/P8nam4KRrFISOb9yC4Hpbs8ks7wbVRvGGkYvQDNfaGVN/ fu3m/1HjfrMi0esTPsofg== X-UI-Out-Filterresults: notjunk:1;V03:K0:MDcp427P/5E=:TatDF61MFOTSICfcJCayhN LDxd/JnoJ/fwIbb+H89LXr3K1xRP/JXduWJm8G7J8VDlUgc9kEeaNPR8E5xrY8wy+yzWTPXgs O7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wjaBaa4FeedjvQ6t2GlBnf1yv woKMpQr/atk2UFImFWlVgQXMAHtG6+3vjTch5Xv1MARZf00AQYc1Zu2G/y3MEJH7mToR2hND4 mq8Fxf4skrBvdMvW6 Received-SPF: pass client-ip=212.227.15.18; envelope-from=deller@gmx.de; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/27 17:46:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Helge Deller , Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Sven Schnelle Signed-off-by: Sven Schnelle Signed-off-by: Helge Deller --- hw/display/artist.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) -- 2.21.3 diff --git a/hw/display/artist.c b/hw/display/artist.c index 6261bfe65b..46043ec895 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -340,14 +340,13 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, { struct vram_buffer *buf; uint32_t vram_bitmask = s->vram_bitmask; - int mask, i, pix_count, pix_length, offset, height, width; + int mask, i, pix_count, pix_length, offset, width; uint8_t *data8, *p; pix_count = vram_write_pix_per_transfer(s); pix_length = vram_pixel_length(s); buf = vram_write_buffer(s); - height = buf->height; width = buf->width; if (s->cmap_bm_access) { @@ -367,20 +366,13 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, pix_count = size * 8; } - if (posy * width + posx + pix_count > buf->size) { - qemu_log("write outside bounds: wants %dx%d, max size %dx%d\n", - posx, posy, width, height); - return; - } - - switch (pix_length) { case 0: if (s->image_bitmap_op & 0x20000000) { data &= vram_bitmask; } - 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; @@ -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) ||