From nobody Mon Jun 13 12:50:13 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2BF3D85631C for ; Mon, 13 Jun 2022 12:50:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LMBHS64Ycz3hLG for ; Mon, 13 Jun 2022 12:50:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ADAB315BD9 for ; Mon, 13 Jun 2022 12:50:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 25DCoCAU023408 for ; Mon, 13 Jun 2022 12:50:12 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 25DCoCAg023407 for bugs@FreeBSD.org; Mon, 13 Jun 2022 12:50:12 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 264656] sh(1): should disregard trailing blanks in variables in arithmetic expressions. Date: Mon, 13 Jun 2022 12:50:13 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: rajeev_v_pillai@yahoo.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655124612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p5X5VOcyYCFOBQk421na2VMZxpa1haxL1d49ADysSAM=; b=sQv8AB9s1Cjm6qKNRtXg+dn4vSH8+BIcE8Qj+Fl5EbtWKf4ffkR9vav/sE8N/HiHIwhFQP Kfr0h8nm+GfKJ5bxBYD8J/Y+OdTjIqgOycRoH4bo1iLG26XsxWEg1wdLjAMllZSXplpd0L bQww324efY+w6lBcol6V9lyBQrHN9jRMnkP3yQzWCtgJgns0Rb1TOzVfMzelfzr3haRWUr aDiJ9ldWucUPgEnyPeDUPasAqq60fqRLR4LeoPqjtMhqGvcLxZskfghc2KrMprinPnKGNh anmg5Xx6EYXFC6Oj2z4s3GacAw9ki2TrEg0VQUV5V++Q+YZeZd+UObr+0bP4JA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655124612; a=rsa-sha256; cv=none; b=L4tE3R49qRYSOqcUMJXGQV4GP0u/JqXtfNehm5FzZgZfev2M/64L6Zz+dTWtEbLAvK/bvy Fd7DSsQpveEdYsPv8+IBgT9g7HRMmA/JWhiiocQh8amYQYhWW0NIQP0Jt0MVoKOXW4hC7D Sgy9+Y4pHaIVx5JRdxG+qS+taq3gkZIksqvJnHEQzApNHStDHPwxEzwp6DWbVpsNqahlLh zrHm0zBicM+v/VEtXSTAteex0uXopSvkPdHou4Bv4JuI+6Tv+5lz6Z/8MCCuu9X88vXuoK E8HRkOCh8lvZRo77oA2+uQT1eUPTYIc6BVlm1pfrgCzefkHdzGq1cn9vW4/0bw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264656 --- Comment #1 from Rajeev Pillai --- A better patch is this one (saves 2 function calls): ---START--- diff -urN bin/sh.orig/arith_yacc.c bin/sh/arith_yacc.c --- bin/sh.orig/arith_yacc.c 2022-05-12 04:53:55.000000000 +0000 +++ bin/sh/arith_yacc.c 2022-06-13 12:39:52.888785000 +0000 @@ -35,6 +35,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -92,6 +93,13 @@ /* NOTREACHED */ } +static inline int is_blank(const char *p) +{ + while (isspace((unsigned char)*p)) + p++; + return *p =3D=3D '\0'; +} + static arith_t arith_lookupvarint(char *varname) { const char *str; @@ -105,7 +113,7 @@ str =3D "0"; errno =3D 0; result =3D strtoarith_t(str, &p); - if (errno !=3D 0 || *p !=3D '\0') + if (errno !=3D 0 || !is_blank(p)) yyerror("variable conversion error"); return result; } ---END--- --=20 You are receiving this mail because: You are the assignee for the bug.=