From nobody Fri Feb 18 01:51:41 2022 X-Original-To: dev-commits-src-branches@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 B5FDD19C1E28; Fri, 18 Feb 2022 01:51:42 +0000 (UTC) (envelope-from git@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 4K0F6j5q4xz4bmG; Fri, 18 Feb 2022 01:51:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645149101; 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; bh=WyZqk3lVxjUX2eVfExtBN5bDSlNQRNjiOINNphX363Y=; b=vLsRCjf6FD1UYiTvkcjEqdoI8/Of7k6EnMVIZSm5b7w71CP+rhMEyoMyGSrOJJo2csrq10 GvtNGYNs9kladV1OADReSj9sUUHtfkwCZBK9j18Nqf9fok2HspbJ/JnGx33oHmdUVLO5Oo 2LYvFnPJHx6AdnBImulyNJi/eCthKwTSqge1hwbSfgvalWLAPbBKAYPRi4GuKnZCHJEJWK o1hCjZ0kHWWSruf03GmbGaz2MoNiKZCv15I40hutEgc/LcaWApTfUWrjzW8MjyoLvcX3z3 WQMK79eLADqY9FEQKSwQg3o2nya1zcdFrWtCVbti/WMwMTnyLJvIMQzLsrtbTw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 9928614DC8; Fri, 18 Feb 2022 01:51:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21I1pfje026207; Fri, 18 Feb 2022 01:51:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21I1pfVL026206; Fri, 18 Feb 2022 01:51:41 GMT (envelope-from git) Date: Fri, 18 Feb 2022 01:51:41 GMT Message-Id: <202202180151.21I1pfVL026206@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: bbb92ab05fa2 - stable/12 - elfctl: fix -e invalid operation error handling List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bbb92ab05fa2d039905ef988ca31b4356b01d964 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645149101; 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; bh=WyZqk3lVxjUX2eVfExtBN5bDSlNQRNjiOINNphX363Y=; b=Zxbkm9WxIjhBxhhxw90pK3gsjYu4tfrtqf+Fx5YRLkum+EN3Fe7kpVeEk0oSZQFI9DhxDG gmdEGkAQqxst9GkEZtJD/xJzxlHF5EzpI7NogKlPgI3orWhsifySQm0tTNJYT1F2tL2uNW x9fmcT048XPt2VZxKSC5VcRgUj3jBbmWBzqzb0cF3vSiSeCxEx++VFsrqiC0A8PTABwBBa Hiu9XZgMVDgrDc4qXUCS6Rp1S6UR5Lxutxb6Irztrbop5dL7xvfouRxxfBcMu+zlQM+6Eh v3pt4cmJUlTQ9BepCV/xZzWlQZsFe5X9InEuzoOQMlXgyYNvJwHXg8wRrvSa2g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645149101; a=rsa-sha256; cv=none; b=Rv+99U36cyCJGFasOdVy+JJnqwUGlkt+u12NBCjnJNAGpV+061wA3tQN1COFRxt+4aUMNv 5ZJda02NGU4U1tA/ta915IDfTEbSLrj51V2dVmQlj6YA9g8rc6rEXeOjPxPXybnJfIBWOT d76avzce/Y7AbviFWB/GdKxOet5tgxd+EkAfPrgXOV9IkRZvqNe0Zz6H+CNYb4nSzdHHHZ V4fA5e32GN2Ubk/E08PfohowE2Cahvx0nJUEIF1Jb0my9DIme1W5pup6fML0i6uXkxdd3F TPpVPcqYjL2/uyWQ8O6f8AoOpj6yGqw07cQplCiCVkRTt2x+rwq/SOWEVQ+Zlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=bbb92ab05fa2d039905ef988ca31b4356b01d964 commit bbb92ab05fa2d039905ef988ca31b4356b01d964 Author: Ed Maste AuthorDate: 2022-02-15 03:30:29 +0000 Commit: Ed Maste CommitDate: 2022-02-18 00:33:47 +0000 elfctl: fix -e invalid operation error handling Validate the operation prior to parsing the feature string, so that e.g. -e 0x1 reports invalid operation '0' rather than invalid feature 'x11'. Also make it an error rather than a warning, so that it is not repeated if multiple files are specified. (Previously an invalid operation resulted in a segfault.) MFC after: 3 days Sponsored by: The FreeBSD Foundation (cherry picked from commit b8185579f457569640f714b6180522619c2f18ea) --- usr.bin/elfctl/elfctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index dbd39f612439..1042712f828a 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -234,6 +234,10 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) input = 0; operation = *feature_str; feature_str++; + + if (operation != '+' && operation != '-' && operation != '=') + errx(1, "'%c' not an operator - use '+', '-', '='", operation); + len = nitems(featurelist); while ((feature = strsep(&feature_str, ",")) != NULL) { for (i = 0; i < len; ++i) { @@ -282,10 +286,6 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) *feature_val = input; } else if (operation == '-') { *feature_val &= ~input; - } else { - warnx("'%c' not an operator - use '+', '-', '='", - feature_str[0]); - return (false); } return (true); }