From nobody Fri Apr 26 08:08:47 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; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=koconnor.net Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1642781583783760.8933759444545; Fri, 21 Jan 2022 08:13:03 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 8AC3416E4184; Fri, 21 Jan 2022 16:12:59 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 08D3716E4179 for ; Fri, 21 Jan 2022 16:12:42 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Fri, 21 Jan 2022 08:12:42 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id q8sm3407669qkl.65.2022.01.21.08.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 08:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rn3fJA0ppRrspXxcJ3oH5qsusqSvk8XWZ3aPAE0zReo=; b=BFO/WPWrBQ9vmHHKT41JH6xkqIw4W4aeNAYMFYS/ujEjnS3xY1bijIqHHHIH7DAhl0 uv0USfszKKmZE8iFaxKR6mmhb/P3JceS0d8A7gFy4mvY0D5d9RsSUNylej+BvVGRLemY uJyLJLOxB00zfELlW0AOEETe9PnIVQNL815sc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rn3fJA0ppRrspXxcJ3oH5qsusqSvk8XWZ3aPAE0zReo=; b=Mt9inrg9fwqEQA/IPteGMGNYDzrujIfQlGyS5lZ2Z8U7KHKIdkV8nRzy16MOEvnCmm aiyY2K0Q4kwZsyF6alV62E/5EOuvuDtY9YXlQVGulbGcm+yuEMUF3Oc5CK2kmHLoPVtj LJ5oChzBGd/wrxrIRTmfBZkAwKco3fawzwITaZAKLN0v+ZaEbVyn9vvBFEnCf0xWkvEW ON+5RAvROFSvdEtaGcufViutndiLc8yBCM2QTCBZ9ltxkJ4pLoedpabVhaB5fdLf91Bz eMiiG8+yTzdOmMflm3DYId2cGzJANFlC8Qqho8K4wCvfLeM6q572uuvURqcinaOMw+kI H4yw== X-Gm-Message-State: AOAM5331aVG20r0WKTGlbCzS4yF/WXT4xWXU92hLe7djg8Y8dqKtQcVe gQNK9n6UzH+961lGdTDs/8Vq5aCZZA5QHA== X-Google-Smtp-Source: ABdhPJwuWRg0zPW+sSOokn4N0QNdC88y92NPJ7f6KHarb7NRxcEI/HLamwblwmOjmjsrSXDr2xpYJQ== X-Received: by 2002:a05:6214:2386:: with SMTP id fw6mr4261314qvb.131.1642781561831; Fri, 21 Jan 2022 08:12:41 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Fri, 21 Jan 2022 11:12:35 -0500 Message-Id: <20220121161235.1996262-1-kevin@koconnor.net> MIME-Version: 1.0 Message-ID-Hash: U4WGZCBX7RECPEYC2A2K4XP6G7Q2AWCT X-Message-ID-Hash: U4WGZCBX7RECPEYC2A2K4XP6G7Q2AWCT X-MailFrom: kevin@koconnor.net 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 CC: Gabe Black X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH] sercon: Fix missing GET_LOW() to access rx_bytes List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" 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-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642781585308100001 The variable rx_bytes is marked VARLOW, but there was a missing GET_LOW() to access rx_bytes. Fix by copying rx_bytes to a local variable and avoid the repetitive segment memory accesses. Reported-by: Gabe Black Signed-off-by: Volker R=C3=BCmelin Signed-off-by: Kevin O'Connor --- src/sercon.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sercon.c b/src/sercon.c index 66a1f24..3019d9b 100644 --- a/src/sercon.c +++ b/src/sercon.c @@ -626,7 +626,7 @@ sercon_check_event(void) u16 addr =3D GET_LOW(sercon_port); u16 keycode; u8 byte, count =3D 0; - int seq, chr; + int seq; =20 // check to see if there is a active serial port if (!addr) @@ -640,20 +640,23 @@ sercon_check_event(void) // read all available data while (inb(addr + SEROFF_LSR) & 0x01) { byte =3D inb(addr + SEROFF_DATA); - if (GET_LOW(rx_bytes) < sizeof(rx_buf)) { - SET_LOW(rx_buf[rx_bytes], byte); - SET_LOW(rx_bytes, GET_LOW(rx_bytes) + 1); + u8 rb =3D GET_LOW(rx_bytes); + if (rb < sizeof(rx_buf)) { + SET_LOW(rx_buf[rb], byte); + SET_LOW(rx_bytes, rb + 1); count++; } } =20 for (;;) { // no (more) input data - if (!GET_LOW(rx_bytes)) + u8 rb =3D GET_LOW(rx_bytes); + if (!rb) return; =20 // lookup escape sequences - if (GET_LOW(rx_bytes) > 1 && GET_LOW(rx_buf[0]) =3D=3D 0x1b) { + u8 next_char =3D GET_LOW(rx_buf[0]); + if (rb > 1 && next_char =3D=3D 0x1b) { seq =3D findseq(); if (seq >=3D 0) { enqueue_key(GET_GLOBAL(termseq[seq].keycode)); @@ -664,12 +667,11 @@ sercon_check_event(void) =20 // Seems we got a escape sequence we didn't recognise. // -> If we received data wait for more, maybe it is just incompl= ete. - if (GET_LOW(rx_buf[0]) =3D=3D 0x1b && count) + if (next_char =3D=3D 0x1b && count) return; =20 // Handle input as individual char. - chr =3D GET_LOW(rx_buf[0]); - keycode =3D ascii_to_keycode(chr); + keycode =3D ascii_to_keycode(next_char); if (keycode) enqueue_key(keycode); shiftbuf(1); --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org