projects
/
libusual.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d89b4d5
)
cfparser: better error handling for set_int
author
Marko Kreen
<markokr@gmail.com>
Thu, 19 Jan 2012 11:49:02 +0000
(13:49 +0200)
committer
Marko Kreen
<markokr@gmail.com>
Thu, 19 Jan 2012 11:49:02 +0000
(13:49 +0200)
usual/cfparser.c
patch
|
blob
|
blame
|
history
diff --git
a/usual/cfparser.c
b/usual/cfparser.c
index 934fb3dd8acf0d88f3567f999700ca5b30828e0b..c1207fb8534afc2204a34203a15f143321a84800 100644
(file)
--- a/
usual/cfparser.c
+++ b/
usual/cfparser.c
@@
-352,9
+352,15
@@
bool cf_set_int(struct CfValue *cv, const char *value)
int *ptr = cv->value_p;
char *end;
long val;
+
+ errno = 0;
val = strtol(value, &end, 0);
- if (end == value)
+ if (end == value || *end != 0) {
+ /* reject partial parse */
+ if (!errno)
+ errno = EINVAL;
return false;
+ }
*ptr = val;
return true;
}