From 459357fa4339716810009fea41209ea47460ae2f Mon Sep 17 00:00:00 2001 From: Marc Boucher Date: Sat, 8 Sep 2001 02:16:51 +0000 Subject: Yet another set of string_to_number() fixes. --- extensions/libipt_FTOS.c | 4 +++- extensions/libipt_LOG.c | 2 +- extensions/libipt_TOS.c | 2 +- extensions/libipt_time.c | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/extensions/libipt_FTOS.c b/extensions/libipt_FTOS.c index b9a5d696..2e3771b8 100644 --- a/extensions/libipt_FTOS.c +++ b/extensions/libipt_FTOS.c @@ -45,7 +45,9 @@ parse_ftos(const unsigned char *s, struct ipt_FTOS_info *finfo) { unsigned int ftos; - string_to_number(s, 0, 255, &ftos); + if (string_to_number(s, 0, 255, &ftos) == -1) + exit_error(PARAMETER_PROBLEM, + "Invalid ftos `%s'\n", s); finfo->ftos = (u_int8_t )ftos; return; } diff --git a/extensions/libipt_LOG.c b/extensions/libipt_LOG.c index f71f4bf8..c7673d91 100644 --- a/extensions/libipt_LOG.c +++ b/extensions/libipt_LOG.c @@ -66,7 +66,7 @@ static struct ipt_log_names ipt_log_names[] static u_int8_t parse_level(const char *level) { - unsigned int lev; + unsigned int lev = -1; if (string_to_number(level, 0, 7, &lev) == -1) { unsigned int i = 0; diff --git a/extensions/libipt_TOS.c b/extensions/libipt_TOS.c index 0e54a08f..bc3cf760 100644 --- a/extensions/libipt_TOS.c +++ b/extensions/libipt_TOS.c @@ -63,7 +63,7 @@ parse_tos(const unsigned char *s, struct ipt_tos_target_info *info) { unsigned int i, tos; - if (string_to_number(s, 0, 255,tos) != -1) { + if (string_to_number(s, 0, 255, &tos) != -1) { if (tos == IPTOS_LOWDELAY || tos == IPTOS_THROUGHPUT || tos == IPTOS_RELIABILITY diff --git a/extensions/libipt_time.c b/extensions/libipt_time.c index 9d1e5597..d8dd5513 100644 --- a/extensions/libipt_time.c +++ b/extensions/libipt_time.c @@ -95,9 +95,10 @@ parse_time_string(unsigned int *hour, unsigned int *minute, const char *time) if (minutes[0] == '0') minutes[0] = ' '; - /* FIXME: error checking */ - string_to_number(hours, 0, 23, hour); - string_to_number(minutes, 0, 59, minute); + if((string_to_number(hours, 0, 23, hour) == -1) || + (string_to_number(minutes, 0, 59, minute) == -1)) { + *hour = *minute = (-1); + } } if ((*hour != (-1)) && (*minute != (-1))) { free(hours); -- cgit v1.2.3