From nobody Sat Apr 20 04:47:49 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 1642637860966509.6807742256384; Wed, 19 Jan 2022 16:17:40 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 603DF16E3FF3; Thu, 20 Jan 2022 00:17:34 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 8872516E3FE8 for ; Thu, 20 Jan 2022 00:17:00 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 19 Jan 2022 16:17:00 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id l22sm574580qtk.55.2022.01.19.16.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 16:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=1JOnZ9n3FoTaGmpEfJU2eBYAjkiZyxOkfoqF5qX+nx0=; b=elAIHXA/sLNHZt/FzrxuTf6g2L9taYqH43ZR0x+XaXZogvLCR2kSlUjS1AMgGO7P5A 16yIrf/Xi2t/F2eNcDKOWb44p0pBnNcIKV2JMhtll6JvwprQKu+w9m9nwYH9/mZ9k5A3 /BmnPxV1SIs4iv5XpDubsJrYKoa14FRyoDFvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=1JOnZ9n3FoTaGmpEfJU2eBYAjkiZyxOkfoqF5qX+nx0=; b=YG+ZtrPnWT6gz1U2/BZ+2psfs5MTEL9+OKi229wUxN3D3C4TgqzQS/RPHq/ADXb9oe LIU2VauSVj64tFLE59+2tYzatvNU7J4L/7PvsICJpaJT5qjTQOieqWitXou5psZ+v/m7 WlgzeqLoaEp0+qaXPcDSFZAB1Dw0BhQlIOgCmutltba6DawiDcfBLoeNGE+auFMzDCzC RNHl13Of2gqWtEuX9RqYAPMkR7DTlb7lD5VtqrjDtV0xGU373XzbN8i6FGv2wkGALE+Y YNJND1UQVap4Z8mduYWCmmk6f+ahxgSzw6YQnjclPQabCagl0vg4IUy2Qrn9sfiBnOSX QD6A== X-Gm-Message-State: AOAM5317jxdMiAzwH93IJehC3NUibdtI621POx3/wFoVFCvgQcgK11f+ YR0bLMF6kG89V5nvhetKHhKJRQ== X-Google-Smtp-Source: ABdhPJyqWnXLaoQjpK6PK42zCH41uc6h99+QV0IPiwgGUBU/l8RNfaSBq/prg04aOe5ISy8pUN0zYA== X-Received: by 2002:a05:6214:2463:: with SMTP id im3mr29588348qvb.104.1642637819358; Wed, 19 Jan 2022 16:16:59 -0800 (PST) Date: Wed, 19 Jan 2022 19:16:58 -0500 From: Kevin O'Connor To: Volker =?iso-8859-1?Q?R=FCmelin?= Message-ID: References: <20220119210849.6196-1-vr_qemu@t-online.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220119210849.6196-1-vr_qemu@t-online.de> Message-ID-Hash: VKWMU6IB5YM6MGZW5IXY753O7KXZEKY6 X-Message-ID-Hash: VKWMU6IB5YM6MGZW5IXY753O7KXZEKY6 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: seabios@seabios.org, Gabe Black X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] Re: [PATCH] sercon: add 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-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: 1642637863021100001 Content-Type: text/plain; charset="utf-8" On Wed, Jan 19, 2022 at 10:08:49PM +0100, Volker R=C3=BCmelin wrote: > The variable rx_bytes is marked VARLOW. Add a missing GET_LOW() > to access rx_bytes. >=20 > Reported-by: Gabe Black > Signed-off-by: Volker R=C3=BCmelin Thanks. Good catch! I think we should fix this by copying the contents into a local variable to hopefully avoid this type of error in the future. Patch below. -Kevin --- 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); _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org