From: Manuel Luis SanmartĂ­n Rozada Date: Thu, 19 Jun 2014 17:14:53 +0000 (+0200) Subject: cmd PUTNOTIF time option: handle double values. X-Git-Tag: collectd-5.3.2~63 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7d1d59fb064f2a9adfba50d3ea5c39ebc6bebd3c;p=collectd.git cmd PUTNOTIF time option: handle double values. Conflicts: src/utils_cmd_putnotif.c --- diff --git a/src/utils_cmd_putnotif.c b/src/utils_cmd_putnotif.c index 7c965084..cba08bfa 100644 --- a/src/utils_cmd_putnotif.c +++ b/src/utils_cmd_putnotif.c @@ -49,10 +49,15 @@ static int set_option_severity (notification_t *n, const char *value) 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);