]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Yet another set of string_to_number() fixes.
authorMarc Boucher <marc@mbsi.ca>
Sat, 8 Sep 2001 02:16:51 +0000 (02:16 +0000)
committerMarc Boucher <marc@mbsi.ca>
Sat, 8 Sep 2001 02:16:51 +0000 (02:16 +0000)
extensions/libipt_FTOS.c
extensions/libipt_LOG.c
extensions/libipt_TOS.c
extensions/libipt_time.c

index b9a5d696abf7188b265d95c3ce40f5749c3ba29d..2e3771b87a9fc4cb8c51e35d7e1d9af07240af92 100644 (file)
@@ -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;
 }
index f71f4bf83cdd6bc84f7c7c4bdcad6d50dc46321a..c7673d91ea43ec7a173d68bbe59f470fb55abaad 100644 (file)
@@ -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;
index 0e54a08f4824a869cdd7163bfb03b2bde1f9dc7d..bc3cf7606b6853a2d6c7176da25d0e57c54d5eb0 100644 (file)
@@ -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
index 9d1e5597d96ed6e1032396ff78a60ee4f81e87d7..d8dd55136590a3ba7049cbeecb3ef80b5b1d2373 100644 (file)
@@ -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);