From nobody Thu Nov 13 20:39:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1582970053; cv=none; d=zohomail.com; s=zohoarc; b=gbCNP76Jn2qKGm9AUGN+CGwBnW/AYlXjHWzwHmCR8F7O9j/emk+ypTMfod5XuBRSqGBthvJ+gckj5bXVdOS7p5y+Xn/b1c+lGEjMfj/DVfWZ3Xw+bhimeGBFYl8uGJGyVAnw1x8QMbMNLFRF+svrVgtDizYy2f176VOjyjaw6mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582970053; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ZG0v8FVysTuE+UkESg/FvlLJyxWq9TgL3tVGtsWFuaI=; b=SHGgfEOqZO3IatmfHu+ihCFy9gMqCmWUFOHDV1H3l+sEF3VQQbV+kPXmts1oFC1Zmgfh6SJBhvG6DB8o8j5jSty7jeIB4uIWF4CxmGTnImJ5Pc5UDxkFSLWeu+Mn32CTTMd758WjAWhcQViCmSCchObIebtyk1tA/wd5oPwvxi0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582970053578507.00278020679286; Sat, 29 Feb 2020 01:54:13 -0800 (PST) Received: from localhost ([::1]:58944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7yp1-0005Rr-49 for importer@patchew.org; Sat, 29 Feb 2020 04:54:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45081) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7yll-0004h0-5D for qemu-devel@nongnu.org; Sat, 29 Feb 2020 04:50:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7ylj-0004nc-SM for qemu-devel@nongnu.org; Sat, 29 Feb 2020 04:50:49 -0500 Received: from smtp.duncanthrax.net ([178.63.180.169]:38424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ylj-0004n2-Bu for qemu-devel@nongnu.org; Sat, 29 Feb 2020 04:50:47 -0500 Received: from [134.3.47.90] (helo=x280.stackframe.org) by smtp.duncanthrax.net with esmtpa (Exim 4.90_1) (envelope-from ) id 1j7ylg-0006kF-Ro; Sat, 29 Feb 2020 10:50:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZG0v8FVysTuE+UkESg/FvlLJyxWq9TgL3tVGtsWFuaI=; b=T3fzgvoGiLMXPUlsje85tL7LTa xpRdnnUVfJs5GrmFucg3w5Bqaykdsyrq0bMNtQPA7Nfi6ZUdF6de52uTXzpO4ffWh5AghlJBzeKOb Afwptto3Tz1k4CA+YGwGRMsFMigxhC1i/ooQNCnkV5KhOpjel8CZLla/eW3fEcBeDUOo=; From: Sven Schnelle To: deller@gmx.de Subject: [PATCH] fix out of bounds check Date: Sat, 29 Feb 2020 10:50:40 +0100 Message-Id: <20200229095040.29616-1-svens@stackframe.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.63.180.169 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: Sven Schnelle , "open list:All patches CC here" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Sven Schnelle --- hw/display/artist.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/display/artist.c b/hw/display/artist.c index f3a1375224..6cc85eb292 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 =3D 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; =20 pix_count =3D vram_write_pix_per_transfer(s); pix_length =3D vram_pixel_length(s); =20 buf =3D vram_write_buffer(s); - height =3D buf->height; width =3D buf->width; =20 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 =3D size * 8; } =20 - 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 &=3D vram_bitmask; } =20 - for (i =3D 0; i < pix_count; i++) { + for (i =3D 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 >>=3D 1; @@ -398,7 +390,9 @@ static void vram_bit_write(ARTISTState *s, int posx, in= t posy, bool incr_x, for (i =3D 3; i >=3D 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, in= t posy, bool incr_x, break; } =20 - for (i =3D 0; i < pix_count; i++) { + for (i =3D 0; i < pix_count && offset + i < buf->size; i++) { mask =3D 1 << (pix_count - 1 - i); =20 if (!(s->image_bitmap_op & 0x20000000) || --=20 2.24.1