From nobody Sat May 30 17:44:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1778582603; cv=none; d=zohomail.com; s=zohoarc; b=Ycph0r/0o1EpkM8BYCXvSYpN/fHJd+uso102GLj2EU+RYXsCAcgwJHgojDyCBum8eq7xZzyGkXUQ+Y9Sl06Hf0vMV9IaI57OkjKyCLDDPiJFlTl8fW1wKcG8kufRgXoRcrq/fBAYv+/64yGkBkHdaSBnl/+AukIDu1VO5CC6j7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778582603; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cHnURK1d/0RKJMXdvYyWDAz5N4wMTvzm1l9ySj3ZS1I=; b=SwZFSOaHNg09LuLkSOP9qEpcF8sygk+k3u7GBaQFPMgokDLyixP32f+ma1xpSB74Cfiv9YOIDBKNo1Rmpo56SGFgaPkPB03YDG1aW8IVXmB3U0HikX9x9kAxlt8eP+rk9QfkhtCQ9TioqzZjcrprki0V48UUERY9+N0LPaj2JPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778582603873367.49234297480723; Tue, 12 May 2026 03:43:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMkZ9-00008m-Mt; Tue, 12 May 2026 06:42:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMkZ6-000074-OV for qemu-devel@nongnu.org; Tue, 12 May 2026 06:42:16 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wMkZ5-0004wH-3f for qemu-devel@nongnu.org; Tue, 12 May 2026 06:42:16 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-43d77f6092eso3317770f8f.2 for ; Tue, 12 May 2026 03:42:14 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45491f8d4c3sm31481680f8f.34.2026.05.12.03.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 03:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778582534; x=1779187334; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cHnURK1d/0RKJMXdvYyWDAz5N4wMTvzm1l9ySj3ZS1I=; b=LRhlm5jQfRm2m5rplOwlbDpvSoTRDhP6ZKhSxoFNAWdam0t6BqCBPKbTOgcr4sNmCn wvrBwo7etkAAenh7bWKYiIjGqzyaVGs2Sxttw84CLMel3LckxmnNmtvK2mTmO/w1/vQ4 6URLAbuzS12hwNsBbFjBm3/henMmIOnh5ahwIkq9AfBVb5jshgPdxo7j1Jovg+e0kDhM XhFFgas/hxnlHdgC4E/ia8pw5TJYIP0g0nV18vVdN/cvUpMhi+kQSAX6VkjPTBkVCM/y ap+/+kFeLF4HHc1txFPBNVuZY0O0oU8Wm8CHe+KuSV/CxzYu0VtYtYdLi38KE8roaVpP IXkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778582534; x=1779187334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cHnURK1d/0RKJMXdvYyWDAz5N4wMTvzm1l9ySj3ZS1I=; b=N1j8P9GHlfyLBPB1Yv5ewXbIKL9m5CfzhgGcsDnDUsem76XPD1N30bM1ye06riU3G2 9hronMyGeFPTm+cekQgM3CWko0EsOfD0XHh+E8Qdz+bNKkt3jqcQ5xJQ8SbpALMKR11S mFeE0GC2eT2s2wQnOdg4kke/3dLrfAuZ/0gKYifzowTLHAhqnfqXe48XtHwmW8mv6Eec IKyDnVJ4kHy9YXYcKotsP0JVy27T5Y9eLBnQ35i05FzeoQSkgw5So9b/gS3bNR1UC34m VaIWU2cGUsACEvKBdP0BYqjcMnSKChkJMAtHys/xS09EC/MMuohFd1XZfMbBsqvjZFVF MpPw== X-Gm-Message-State: AOJu0YwG62HmVea6B1GPnc2GWccsaKQVGo0ft1aBWXqanhVctzY8uLY1 F0be0dBOGyWCq/nI13pSugRFDv2l84LD3T2eX0jANtdK24blI4eujaD9aDaS8K+uVPGQWhaRNtk kMF8D X-Gm-Gg: Acq92OHeAa+6Dv2o3te4SoqPb/+KjLMOi7Y11QghSMCX/60gSJNDmcAe2JYQjcEtt1m 4rD4/nvItGQqK20woyaguCOoZL8xcODo1CfcwlF5UTsBAZtWvMoNmbK1rFnEzr22A1VVj02onWp 1J/b4FUrD7XFEUZIp6VdKFD5QNi2XTiPuV6aXMGs5zBKIOi5Px1sV+vfotAt+XC/kySEBH5xzT3 XS4I/eV1Tb4+/sujG19PhLEI8H65HxadfjWsdqkj33GhGnkBjYL5/4fp7nc4HCRL0r4ekgtLyVx IyZ+eUK7ArVt2ZF3qeBfwBsmS0Ei6wE9AUqKBHiGLp7murQkxyvrY+VvOlGn8WbvCtZ/4m5p+vv 7/zElEjXEZr7drTHu3y0JuTbKhTFucmktvimlL2oHvYfXuXcvqZfF9NGqjPP+Nuo8S+WJ3bSHWw XPn6oXbBGD6nQC+3fl5mkSjw67vWlowcnJ7HEcCNHjulZR9H+HthB8k0iLJ7+T1WDK8HIxP4cJW LQjJpmKmF1PuHn/qrWGPAJs4mTyx1g= X-Received: by 2002:a5d:5d85:0:b0:43c:fb48:6856 with SMTP id ffacd0b85a97d-45b12fd27bamr3669145f8f.13.1778582533728; Tue, 12 May 2026 03:42:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 1/2] ui/vt100: Standardize on uint8_t for "ch" byte variables Date: Tue, 12 May 2026 11:42:09 +0100 Message-ID: <20260512104210.3330835-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260512104210.3330835-1-peter.maydell@linaro.org> References: <20260512104210.3330835-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1778582605558158500 Content-Type: text/plain; charset="utf-8" The vt100 code is rather confused about how it handles bytes of data to be sent to the terminal: * vt100_input() takes a buffer of uint8_t * each byte is passed to vt100_putchar(), which takes "int ch" * that calls vt100_put_one(), which also takes "int ch" * vt100_put_one() sets TextCell::ch, which is uint8_t again * various places pass the TextCell:ch value to vt100_putcharxy(), which takes "int ch" again, but uses it unchecked as an index into a 256-entry array This confuses Coverity (e.g. CID 1659590) and the reader, who may be unsure whether the "int" variable really does hold only valid byte values 0..255 and whether we need to bounds-check before doing array dereferences. Standardize on keeping known-byte data in uint8_t all the way through. Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/vt100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/vt100.c b/ui/vt100.c index e2fba82252..7e373766bc 100644 --- a/ui/vt100.c +++ b/ui/vt100.c @@ -61,7 +61,7 @@ static void image_bitblt(pixman_image_t *image, xs, ys, 0, 0, xd, yd, w, h); } =20 -static void vt100_putcharxy(QemuVT100 *vt, int x, int y, int ch, +static void vt100_putcharxy(QemuVT100 *vt, int x, int y, uint8_t ch, TextAttributes *t_attrib) { static pixman_image_t *glyphs[256]; @@ -468,7 +468,7 @@ static uint32_t bh_utf8_decode(uint32_t *state, uint32_= t *codep, uint32_t byte) return *state; } =20 -static void vt100_put_one(QemuVT100 *vt, int ch) +static void vt100_put_one(QemuVT100 *vt, uint8_t ch) { TextCell *c; int y1; @@ -606,7 +606,7 @@ static void vt100_restore_cursor(QemuVT100 *vt) vt->t_attrib =3D vt->t_attrib_saved; } =20 -static void vt100_putchar(QemuVT100 *vt, int ch) +static void vt100_putchar(QemuVT100 *vt, uint8_t ch) { int i; int x, y; --=20 2.43.0 From nobody Sat May 30 17:44:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1778582591; cv=none; d=zohomail.com; s=zohoarc; b=nycDx1hOtqO1VD1IsPaZdlWrzDJhr/dYzvpXBfhmSWgXaoGfKNmpHP5Ir+nOtoFdrRUvMY1sl9wk1pzdmsNVYje+Zrw2uyxi9A+U7i+QrKOD3y0i17mgz6W+jzKNf/JKQW5bgI6vVsqKnGw0Sriliho8lEE7ecoyjunmesM/4N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778582591; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MFZUlls1c5X4NMYGrbnJvphrDhgD5jx9UANy2AKruuc=; b=RtDX3Y/AGiIxSOhaEpc03gJD4EoUroOaQYHI6sJ+BgQsdFXqiVdhiqjmtds++xN6v3/XvCZDf6M2La56b3TInabfjw0x6ESBkry2ZRTmZERtzx4d8Hhm2nljudp9+i8ChDSC5F48h5xhMLD0Lr+u+DIspdYdI5CRm1EK7nU4uZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778582590896146.9177369263374; Tue, 12 May 2026 03:43:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMkZ8-00007w-FX; Tue, 12 May 2026 06:42:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMkZ7-00007j-KL for qemu-devel@nongnu.org; Tue, 12 May 2026 06:42:17 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wMkZ5-0004wY-V4 for qemu-devel@nongnu.org; Tue, 12 May 2026 06:42:17 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-44b330c5cc6so3883759f8f.1 for ; Tue, 12 May 2026 03:42:15 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45491f8d4c3sm31481680f8f.34.2026.05.12.03.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 03:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778582534; x=1779187334; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MFZUlls1c5X4NMYGrbnJvphrDhgD5jx9UANy2AKruuc=; b=vBI46e95+eVq7WpJ5RPrxXET+LMEbb/risLAynu581ByME8tnMcij5p9nRU1ms055O W2qf34wc2DHfFVrz7/nAi6QoKbMFUeLcKSU+bY30sLcNRiZ82nElUvuTiDRdq6s7bsI6 m78zprU//p7H2+sXj+cqyV8S6SqlRXGGbW4kaM+Z5oD1FN5oHxJN35xFptqC6Ng+5zy3 oylAomEYQCj4wfC+tVTOmIGlPwKGoZ+vrbwSLvGvZVrdt6ldM3PNMKCWRIAF1vXDFsLX oPag95lwyfahi5SN7Nz+SzmQQN2vy9DDxLxF1a4jqDOc1lClxZpGAt/w21kporQ7jZjT js2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778582534; x=1779187334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MFZUlls1c5X4NMYGrbnJvphrDhgD5jx9UANy2AKruuc=; b=anoXw3zo1iU2qKSMCZk+oG1bTgdymzhSrbZLy2x4H1agwfW4GPhTWp+0nmITYeQmqp s4zku0ZYOgmZKklkp1SeAuVPWpVtph+ujWXltO6k/5hybAg4A1eY5faempbv3WqUyJjl zdKjOKSoGIv+dLFuwLKdXIKsLjsMRZr9L+OpRWJ/B+KiN+TExAVEncrD31VhyKfyTcnB OGGVCN0oB7Ul4DfAkKHNaHlXyVUu3Qu8xMPmOn+w67Fb/CPm90Lt4RJAAwLDKRevcI1C SLIjQxX/Io+GxCFj746PYMq9xxDdTfkv+1J93UhQKBrwooNpug4mn5ZBu5ISUPKMoALO RaxA== X-Gm-Message-State: AOJu0YwAtPjONqtb4uHKPOHf0Tjq3CbdfVUTEevdo7eMNiFInBY9tmwN bwnk5wPAddIoxOcOaheaU5LVPyfbCnvR7EeO0YSP0IrGMn8K+Kilt+EuO5bVzFCIvAmN3acJJ/j E0B2j X-Gm-Gg: Acq92OH7By4Zfjy9L9t/WHxgrZttNhjWo27ZjD/c1oJ5TODL+pszFdeSVS/KDJZnKBY 9b2PZtJiRaO3OxGpyHMMv3MPL/bR1lq3UTndCbk7qrSnLXw0UKW3XFBLL/D87svrY3od4VjRDix hnVohQfCbeoAn3WY5ISZXj1pwZLYpCwUuf8WUobs0L180rhjpTlcqEuIHDpG2b/U1tOcCyBD0ga SmD7k6GI4TlgVzB9lSDbo2dTV2NgUONXfjT81liUQXbl2u4F5Xc8WhzWVidAKOByaLSjGJAXuUN BvkGGdYgtROm7FBVlDojwUEX6ISkwQn29NiCOD1zmmN23uO/zcHuVxLvyzY4qJzmZPtZTzocU6N ez9tcLqiI+7J1q5dIXYy3hE+HuYKw9aHj5HyjyPVjsxbiK2zyejsEyupzu95EIl96XTZ6GUX02D GWNulza7GE3Er43D/Ocey+yBV07wptDchHSVcU4SSiJVUv0ZOmBsksLbBnTs2MGtzO5FmMe0Cxn s3pXzhh7Xy6F3HXfEa7h0LjoPHw7cQ= X-Received: by 2002:a05:6000:61e:b0:43e:aa43:243 with SMTP id ffacd0b85a97d-4515da96528mr44021450f8f.43.1778582534572; Tue, 12 May 2026 03:42:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 2/2] ui/vt100: Take byte as uint8_t in bh_utf8_decode() Date: Tue, 12 May 2026 11:42:10 +0100 Message-ID: <20260512104210.3330835-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260512104210.3330835-1-peter.maydell@linaro.org> References: <20260512104210.3330835-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1778582591761158501 Content-Type: text/plain; charset="utf-8" The bh_utf8_decode() UTF8 decoder takes its next byte as a "uint32_t byte" parameter, but it assumes it to be in bounds as it immediately indexes into its array with it. Use "uint8_t" as the argument type instead. This moves us away from the upstream implementation slightly, but it is the same type as we use in the one callsite, and it makes it clear that we can't be indexing off the end of the array with this guest-derived data. This probably helps make Coverity a bit happier (CID 1659590). Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- I was tempted to split the utf8d[] array in two, because it is really two entirely disjoint data structures -- we look up the input byte in elements 0..255, and then we look up (*state + type) in elements 256..363. But I left it alone. --- ui/vt100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vt100.c b/ui/vt100.c index 7e373766bc..f8140cfa85 100644 --- a/ui/vt100.c +++ b/ui/vt100.c @@ -438,7 +438,7 @@ static void vt100_clear_xy(QemuVT100 *vt, int x, int y) #define BH_UTF8_ACCEPT 0 #define BH_UTF8_REJECT 12 =20 -static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint32_t = byte) +static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint8_t b= yte) { static const uint8_t utf8d[] =3D { /* character class lookup */ --=20 2.43.0