From 7d1d59fb064f2a9adfba50d3ea5c39ebc6bebd3c 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. Conflicts: src/utils_cmd_putnotif.c --- src/utils_cmd_putnotif.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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); -- 2.11.0