From nobody Fri Feb 18 01:50:58 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 5B71219C0B2C; Fri, 18 Feb 2022 01:50:58 +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 4K0F5t28zNz4bJt; Fri, 18 Feb 2022 01:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645149058; 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=pzfI6Lc4ixzy1L4xLI6KKx1Xj6+XmLRaYVCe/b4QlQ4=; b=ol8DdnC+F5tu7h+7zgKga6hwMH7PXPn/+FJEFXUuq9zjW2iE4UHAmDNo19cepJlXdNgT0x rMnuLHq+fSbxPnLRAHP7zUtSVhtl99LSG49o3B6C3oEYocbMeH0fQEDyRq6alvgm/iAcFf zS6KPYFBLsuo1tuLy+Gor/i0WhIzMdx12Jv8aO5ThtCt6u4uyWPr0R3gNGbScfxznno5mJ 10xhOW5WrjWvP33xEOGFribMD8O2a3v5b9MOqWgjQe+MsEqc7gbxrBBc7y/9F5BGG2Ssqe 18s9A2r6dALcxX7O8xfG5lSKkoLF+u+yEnqhD9ROBTGOs06jxN8v5FR8TyN9Hw== 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 2A16214F04; Fri, 18 Feb 2022 01:50:58 +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 21I1owQJ025949; Fri, 18 Feb 2022 01:50:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21I1owQx025948; Fri, 18 Feb 2022 01:50:58 GMT (envelope-from git) Date: Fri, 18 Feb 2022 01:50:58 GMT Message-Id: <202202180150.21I1owQx025948@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: f6c74bacf5e7 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: f6c74bacf5e73f41e7b2d3ba1a66d1d43f7ea785 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645149058; 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=pzfI6Lc4ixzy1L4xLI6KKx1Xj6+XmLRaYVCe/b4QlQ4=; b=qLR5RM5R5u/bAIqUgX9/hnA0z/b6y9KGPn89oxhTkhszra6RXuU99vdui9zQ1OESGenCA+ Pc+9Y5WIvFzsAWdkpsIxQd7r/gzjBwj13mTQMEuV4G1/JfE89njwo53bLbqFYh13kQs0oj /lhnwz9s2Tk2gaknLTMWj3ZQwFMnfpd76Uz1N8Hr67LEUMtq4562ta79HCaG8lVZKknM5w /TUnnW6TfInxfWxZEUoLq7YT2TA8ztuOc3xz9JbKfzwHkhUsOn5FBCP33xAmST19g+to57 FTon5EwZWKsfgmqFThd237D5l0FuNvUzDCs6eigbmmRjAS4d0R0/aCwf/Z5utA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645149058; a=rsa-sha256; cv=none; b=teu8oM1hQm+tknfJ4zLyNMHp34h5zgvSMfQKjT47hExqqHFA9r0aAru2zdBksFZrzrJiBX 2HJdvpP7W6GC5LqWnjmLNmoLjfhXRxkcp7fNZ2dtszpOyQvvJjyJBalwO7mA41ayobJ5Fx pHSjGyUZ2vYv9wsTiRKYe4NIHltmpjXnXwNoCJ/gp25YPWC8Dw2H3x/v8X+ycMyIDL5TF5 XhPXSugebvmkD6kIde52D+/opw7ncxTE1vptLppAIz7WtEnYHm+Sg9uruv6LKhZMEpZD0R CZ0XFmuKtj3WQqsGr86WUUs6XTk9SwZfpNZtDtEji+CgbXfwkWz584J1/y5djA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=f6c74bacf5e73f41e7b2d3ba1a66d1d43f7ea785 commit f6c74bacf5e73f41e7b2d3ba1a66d1d43f7ea785 Author: Ed Maste AuthorDate: 2022-02-15 03:30:29 +0000 Commit: Ed Maste CommitDate: 2022-02-18 00:31:26 +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 de14551f76d9..9463372f6740 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -230,6 +230,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) { @@ -278,10 +282,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); }