From: Vincent Lefevre Date: Tue, 19 Jun 2018 07:45:29 +0000 (+0200) Subject: mutt_atol: better error handling. X-Git-Tag: mutt-1-11-rel~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cdd88479d4584894dbb7e9b0f658aac6fa67d4a;p=mutt mutt_atol: better error handling. * Detect overflow on negative numbers too (< LONG_MIN). * Distinguish between format error and number overflow as already expected (e.g. for pgp_timeout and smime_timeout). --- diff --git a/lib.c b/lib.c index f008aae0..78e02dfe 100644 --- a/lib.c +++ b/lib.c @@ -1079,9 +1079,10 @@ int mutt_atol (const char *str, long *dst) errno = 0; *res = strtol (str, &e, 10); - if ((*res == LONG_MAX && errno == ERANGE) || - (e && *e != '\0')) + if (e && *e != '\0') return -1; + if (errno == ERANGE) + return -2; return 0; }