X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils_cmd_putnotif.c;h=d3cf3834dea42885ff6df3d4695b53bf38d64872;hb=1ecef4ca6f6ba7005109df6520949e578a483ca3;hp=3496ca9329500c70aaaae477135cbd159378d1d0;hpb=5e7fbbcce89a63aeac198063fa1c8922b0b1f64c;p=collectd.git diff --git a/src/utils_cmd_putnotif.c b/src/utils_cmd_putnotif.c index 3496ca93..d3cf3834 100644 --- a/src/utils_cmd_putnotif.c +++ b/src/utils_cmd_putnotif.c @@ -49,13 +49,18 @@ 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); + n->time = DOUBLE_TO_CDTIME_T (tmp); return (0); } /* int set_option_time */