From nobody Tue Feb 15 03:41:30 2022 X-Original-To: dev-commits-src-main@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 36551194AA0F; Tue, 15 Feb 2022 03:41:31 +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 4JyRhq12Dgz4Zc5; Tue, 15 Feb 2022 03:41:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644896491; 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=c41x8lZ07whhBzCYm+ZKe51QZrIotGjtJc0N6UxNbII=; b=rTKkRbgmY0GwOTTEEu60W0uIN+RX/oP7kPc+wmyFdrvuEWvvWCdLA789U0o4vnP45+EXco l7cHpqcoiJZk7DILYNqAdPfJ/RmEOduFAUzu4jzIKJXZSwkz74CGb08+WHsOOge3lGq9+y eYx6O+atIylxNSVrgFMdtKG9RFvXjmeNJACYgdh3J/s8ZujHD6Tsfe/utqjV83qklUiFlj T9UWjC8ggmbhCKV4wmOZ6WfYZFNQV4ykaHKxjfVziZ0ffaPNPcmxO/yWitnLUGqFNtVFlp iz97RSknF8Hzym0Os2MW70ZGtMclTHS4K9QHemaSdzh2X5XmOiYhle3k9oBjww== 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 03C911B591; Tue, 15 Feb 2022 03:41:31 +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 21F3fUhc076678; Tue, 15 Feb 2022 03:41:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21F3fUaS076677; Tue, 15 Feb 2022 03:41:30 GMT (envelope-from git) Date: Tue, 15 Feb 2022 03:41:30 GMT Message-Id: <202202150341.21F3fUaS076677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: b8185579f457 - main - elfctl: fix -e invalid operation error handling List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b8185579f457569640f714b6180522619c2f18ea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644896491; 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=c41x8lZ07whhBzCYm+ZKe51QZrIotGjtJc0N6UxNbII=; b=ef+dYCePdL4dfWecj4VCe1aJQ6n7nKAAFj6xDJYm5iC70k24fLIN/Mg4FaQgHbbeH7i/aN cu6sJ/hiNejt5E971bUoV5MzJ69v8qYv6kOJ35yHMyEOwJnV24f1ecavFR/t1RMvRDV6jF HcO2OmRkD5Y2PfA21zFlg/ErIyLBDkoD48H9SZzNX0IkRRj3b3tkN/94YkYF7zT+5X6fEz P+48zQT3VYMASLh+6vH4Q9HErIJpvlTFHiC/xg4f/DvFJ8daTI4kq8NGY58EyW+XstRcB3 tX2ulALJ+8bYLqKx6d9W+kOtdecd6FiRlo84b9C2OLtdAGbcnP9bvT4Y2ADU1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644896491; a=rsa-sha256; cv=none; b=cu7mSP0IqFA3Emn3EndO3OWFgks3iqGN8j6S1VpHcOFYXedUBJ8kCmEquq3CW3XtxW2Fdl okoRYQ5QXECRJCUQQL1C5Py5lKJJLgrHvq/J1y32QhJLJMusCBmKcGuHzpYIu43MAa4EUk /72C6c+9Er7GSzO+pcAHIuAgCYcLpjR+kg6j0xZ0+DQuv0naFWnaYX38UfMkCV1p5kDqfr KHYFJde0JtHS8K82F9Owlk7kXQgtn61GZkZQsfA52GsVPl2pLYgdXGzsk/qnHR7XTxYEfx WoytuCTlNuZFmh3FlW8GNBjmYokaMpHJJcVuzGDchjw5BONQiTvj/Y2z1Svf/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b8185579f457569640f714b6180522619c2f18ea commit b8185579f457569640f714b6180522619c2f18ea Author: Ed Maste AuthorDate: 2022-02-15 03:30:29 +0000 Commit: Ed Maste CommitDate: 2022-02-15 03:35:03 +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 --- 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 8b3d20d4a9c7..993349d4ec4c 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -232,6 +232,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) { @@ -280,10 +284,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); }