From: Marko Kreen Date: Thu, 19 Jan 2012 11:17:51 +0000 (+0200) Subject: cfparser: use strtol() in set_int X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=5c986914241a69683844fc01a465ed3c4e535399;p=libusual.git cfparser: use strtol() in set_int This allows octal and hex prefixes, also error detection. --- diff --git a/usual/cfparser.c b/usual/cfparser.c index 55dbd75..934fb3d 100644 --- a/usual/cfparser.c +++ b/usual/cfparser.c @@ -350,7 +350,12 @@ bool cf_load_file(const struct CfContext *cf, const char *fn) bool cf_set_int(struct CfValue *cv, const char *value) { int *ptr = cv->value_p; - *ptr = atoi(value); + char *end; + long val; + val = strtol(value, &end, 0); + if (end == value) + return false; + *ptr = val; return true; }