summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e7fbbc)
raw | patch | inline | side by side (parent: 5e7fbbc)
author | Manuel Luis Sanmartín Rozada <manuel.luis@gmail.com> | |
Thu, 19 Jun 2014 17:14:53 +0000 (19:14 +0200) | ||
committer | Manuel Luis Sanmartín Rozada <manuel.luis@gmail.com> | |
Thu, 19 Jun 2014 17:14:53 +0000 (19:14 +0200) |
src/utils_cmd_putnotif.c | patch | blob | history |
index 3496ca9329500c70aaaae477135cbd159378d1d0..d3cf3834dea42885ff6df3d4695b53bf38d64872 100644 (file)
--- a/src/utils_cmd_putnotif.c
+++ b/src/utils_cmd_putnotif.c
static int set_option_time (notification_t *n, const char *value)
{
- time_t tmp;
-
- tmp = (time_t) atoi (value);
- if (tmp <= 0)
+ char *endptr = NULL;
+ double tmp;
+
+ errno = 0;
+ tmp = strtod (value, &endptr);
+ if ((errno != 0) /* Overflow */
+ || (endptr == value) /* Invalid string */
+ || (endptr == NULL) /* This should not happen */
+ || (*endptr != 0)) /* Trailing chars */
return (-1);
- n->time = TIME_T_TO_CDTIME_T(tmp);
+ n->time = DOUBLE_TO_CDTIME_T (tmp);
return (0);
} /* int set_option_time */