From owner-dev-commits-src-all@freebsd.org Sat Jan 23 15:25:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D3F384F5E32; Sat, 23 Jan 2021 15:25:37 +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 4DNKhK5jlWz4b2m; Sat, 23 Jan 2021 15:25:37 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B7356138B0; Sat, 23 Jan 2021 15:25:37 +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 10NFPbBG002391; Sat, 23 Jan 2021 15:25:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10NFPbIh002389; Sat, 23 Jan 2021 15:25:37 GMT (envelope-from git) Date: Sat, 23 Jan 2021 15:25:37 GMT Message-Id: <202101231525.10NFPbIh002389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9940ac808de7 - main - elfctl: Fix type errors. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9940ac808de7b7d4ed0408c3e739f667dca06d3b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jan 2021 15:25:37 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9940ac808de7b7d4ed0408c3e739f667dca06d3b commit 9940ac808de7b7d4ed0408c3e739f667dca06d3b Author: Konstantin Belousov AuthorDate: 2021-01-23 10:45:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-01-23 15:24:32 +0000 elfctl: Fix type errors. Target value for val has uint32_t type, not uint, adjust used constant. Change val type to unsigned so that left and right sides of comparision operator do not expose different signed types of same range [*]. Switch to unsigned long long and strtoll(3) so that 0x80000000 is accepted by conversion function [**]. Reported by: kargl [*] Noted by: emaste [**] Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28301 --- usr.bin/elfctl/elfctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index 300a66eb516e..bcdd1be394a9 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -249,13 +250,13 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) if (i == len) { if (isdigit(feature[0])) { char *eptr; - long val; + unsigned long long val; errno = 0; - val = strtol(feature, &eptr, 0); + val = strtoll(feature, &eptr, 0); if (eptr == feature || *eptr != '\0') errno = EINVAL; - else if (val > UINT_MAX) + else if (val > UINT32_MAX) errno = ERANGE; if (errno != 0) { warn("%s invalid", feature);