dovecot-2.2: lib: strnum - ensure str_to_uintmax doesn't return ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 16 10:38:47 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9899cc178d0d
changeset: 17811:9899cc178d0d
user:      Phil Carmody <phil at dovecot.fi>
date:      Tue Sep 16 13:38:30 2014 +0300
description:
lib: strnum - ensure str_to_uintmax doesn't return a value on error
It was clobbering the _r parameter even though the spec says it shouldn't.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/strnum.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (20 lines):

diff -r fc79ac9cc378 -r 9899cc178d0d src/lib/strnum.c
--- a/src/lib/strnum.c	Tue Sep 16 12:32:09 2014 +0300
+++ b/src/lib/strnum.c	Tue Sep 16 13:38:30 2014 +0300
@@ -106,10 +106,12 @@
 int str_to_uintmax(const char *str, uintmax_t *num_r)
 {
 	const char *endp;
-	int ret = str_parse_uintmax(str, num_r, &endp);
-	if ((ret == 0) && (*endp != '\0'))
-		ret = -1;
-	return ret;
+	uintmax_t n;
+	int ret = str_parse_uintmax(str, &n, &endp);
+	if ((ret != 0) || (*endp != '\0'))
+		return -1;
+	*num_r = n;
+	return 0;
 }
 
 #define STR_TO_U__TEMPLATE(name, type)				\


More information about the dovecot-cvs mailing list