From 9ce2683f2d98b0f3976e7762382425b21a55ebd2 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 21 Jan 2019 22:28:02 -0500 Subject: [PATCH] roken: strtoull.c negation is a no-op on unsigned integer strtoull() returns an unsigned long long. However, then the input string represents a negative number the return value is supposed to be the unsigned representation of the negative value. Before applying the negation the value must be cast to (long long). Change-Id: Icf9e75400ff736819b1f7e0e6fb3c8abd707a23a --- lib/roken/strtoull.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/roken/strtoull.c b/lib/roken/strtoull.c index cdf59448f..94530e574 100644 --- a/lib/roken/strtoull.c +++ b/lib/roken/strtoull.c @@ -119,9 +119,8 @@ strtoull(const char * nptr, char ** endptr, int base) noconv: errno = EINVAL; } else if (neg) - acc = -acc; + acc = -(long long)acc; if (endptr != NULL) *endptr = (char *)(any ? s - 1 : nptr); return (acc); } -