X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cmd_putnotif.c;h=cba08bfa15b3092f249e1cf4503b49ddd2c05f8f;hb=7d1d59fb;hp=7c965084318750244091c75c317a01c6271ad2bd;hpb=f5c294b7355cee34df44b1c5b8ac3ef7b85664cd;p=collectd.git 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);