Date: Sat, 23 Jan 2021 15:25:37 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 9940ac808de7 - main - elfctl: Fix type errors. Message-ID: <202101231525.10NFPbIh002389@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9940ac808de7b7d4ed0408c3e739f667dca06d3b commit 9940ac808de7b7d4ed0408c3e739f667dca06d3b Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-01-23 10:45:51 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> 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 <getopt.h> #include <libelf.h> #include <stdbool.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101231525.10NFPbIh002389>