From 0e3ebc63e6f3c814bf732e01a867c8640c67998e Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Mon, 18 Jan 2010 14:07:41 +0000 Subject: [PATCH] Print sizes up to INT64_MAX in md_prthumanval(). PR: bin/125365 Approved by: trasz (mentor) MFC after: 2 weeks --- sbin/mdconfig/mdconfig.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 107a25975097..ec667c51ad52 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -454,14 +454,15 @@ static void md_prthumanval(char *length) { char buf[6]; - uint64_t bytes; + uintmax_t bytes; char *endptr; - bytes = strtoul(length, &endptr, 10); - if (bytes == (unsigned)ULONG_MAX || *endptr != '\0') + errno = 0; + bytes = strtoumax(length, &endptr, 10); + if (errno != 0 || *endptr != '\0' || bytes > INT64_MAX) return; - humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), - bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(buf, sizeof(buf), (int64_t)bytes, "", + HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); (void)printf("%6s", buf); }