projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9e2dd42
)
src/common.c: parse_values: Add error handling.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Sun, 31 Oct 2010 14:44:18 +0000
(15:44 +0100)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Sun, 31 Oct 2010 14:44:18 +0000
(15:44 +0100)
src/common.c
patch
|
blob
|
history
diff --git
a/src/common.c
b/src/common.c
index
1cef5e1
..
87d7bf0
100644
(file)
--- a/
src/common.c
+++ b/
src/common.c
@@
-981,8
+981,20
@@
int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds)
if (strcmp ("N", ptr) == 0)
vl->time = cdtime ();
else
- /* FIXME: Add error checking here. */
- vl->time = DOUBLE_TO_CDTIME_T (atof (ptr));
+ {
+ char *endptr = NULL;
+ double tmp;
+
+ errno = 0;
+ tmp = strtod (ptr, &endptr);
+ if ((errno != 0) /* Overflow */
+ || (endptr == ptr) /* Invalid string */
+ || (endptr == NULL) /* This should not happen */
+ || (*endptr != 0)) /* Trailing chars */
+ return (-1);
+
+ vl->time = DOUBLE_TO_CDTIME_T (tmp);
+ }
}
else
{