From nobody Mon Dec 30 17:40:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1710205047864311.4573455487365; Mon, 11 Mar 2024 17:57:27 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 61A0321C35; Tue, 12 Mar 2024 00:57:23 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id AC3E6216A5 for ; Tue, 12 Mar 2024 00:57:06 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) (Authenticated sender: daniel@drv.nu) by oak.drv.nu (Postfix) with ESMTPSA id B2ABB103045; Mon, 11 Mar 2024 17:57:04 -0700 (PDT) From: Daniel Verkamp To: seabios@seabios.org Date: Mon, 11 Mar 2024 17:56:40 -0700 Message-ID: <20240312005655.1372299-1-daniel@drv.nu> MIME-Version: 1.0 X-Spam-Level: ** Message-ID-Hash: E644Y3KVQJF4J7MMKQDCE76R3RW3LZDU X-Message-ID-Hash: E644Y3KVQJF4J7MMKQDCE76R3RW3LZDU X-MailFrom: daniel@drv.nu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH v2] vgasrc: round up save/restore size List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZM-MESSAGEID: 1710205049372100001 Content-Type: text/plain; charset="utf-8" When calculating the size of the buffer required for the VGA/VBE state, round up rather than truncating when dividing the number of bytes to get the number of 64-byte blocks. Without this modification, the save state function will write past the end of a buffer of the size requested. Signed-off-by: Daniel Verkamp --- V2: apply the fix to VGA function 101c as well vgasrc/vbe.c | 2 +- vgasrc/vgabios.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index 66afb011..1a0948cf 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -242,7 +242,7 @@ vbe_104f04(struct bregs *regs) if (ret < 0) goto fail; if (cmd =3D=3D 0) - regs->bx =3D ret / 64; + regs->bx =3D DIV_ROUND_UP(ret, 64); regs->ax =3D 0x004f; return; fail: diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 198ee555..73ba1c3d 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -1081,7 +1081,7 @@ handle_101c(struct bregs *regs) if (ret < 0) goto fail; if (cmd =3D=3D 0) - regs->bx =3D ret / 64; + regs->bx =3D DIV_ROUND_UP(ret, 64); regs->al =3D 0x1c; fail: return; --=20 2.43.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org