From ada80db25b508f681fd021cd4cd45d8fd29d8f59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Luis=20Sanmart=C3=ADn=20Rozada?= Date: Thu, 19 Jun 2014 19:14:53 +0200 Subject: [PATCH] cmd PUTNOTIF time option: handle double values. --- src/utils_cmd_putnotif.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 */ -- 2.30.2