From 5d11638277383d5fbccca2c8929894720bf86eb1 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Mon, 25 Sep 2017 13:50:13 +0200 Subject: Fixes timeout parsing. --- src/config.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 6243db2..ad060a5 100644 --- a/src/config.c +++ b/src/config.c @@ -250,48 +250,14 @@ static int parse_timeout_option const char * const param ) { - int valc, timeout_msec; + int timeout_msec; const int prev_errno = errno; conf->enable_timeout = 1; errno = 0; - valc = scanf(param, "%d", &timeout_msec); - - if (valc == EOF) - { - if (errno == 0) - { - RELABSD_S_FATAL - ( - "Unexpected end of file while reading timeout option." - ); - } - else - { - RELABSD_FATAL - ( - "An error occured while reading timeout option: %s.", - strerror(errno) - ); - } - - errno = prev_errno; - - return -1; - } - else if (valc < 1) - { - RELABSD_S_FATAL - ( - "Invalid parameter count for timeout option (1 int expected)." - ); - - errno = prev_errno; - - return -1; - } + timeout_msec = atoi(param); if (timeout_msec <= 0) { @@ -301,7 +267,10 @@ static int parse_timeout_option timeout_msec, INT_MAX ); + + return -1; } + memset((void *) &(conf->timeout), 0, sizeof(struct timeval)); conf->timeout.tv_sec = (time_t) (timeout_msec / 1000); -- cgit v1.2.3-70-g09d2