]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
fix stupid bug introduced with too-lazy "-t" checking.
authorHarald Welte <laforge@gnumonks.org>
Sun, 21 Oct 2001 14:11:54 +0000 (14:11 +0000)
committerHarald Welte <laforge@gnumonks.org>
Sun, 21 Oct 2001 14:11:54 +0000 (14:11 +0000)
ip6tables-restore.c
iptables-restore.c

index d0c778a3bd7f5a3fbedbea5b205f5f4695bd4501..415f1e4d35152401d118dd2c0c8d9adbbd2404f2 100644 (file)
@@ -293,22 +293,6 @@ int main(int argc, char *argv[])
                                 /* start command parsing at start of line */
                                 parsestart = buffer;
                         }
-
-                       /* prevent iptables-restore from crashing in do_command
-                        * when someone passes a "-t" on the line.
-                        *  - Ben Reser <ben@reser.org> */
-                       if (strstr(buffer, "-t")) {
-                               exit_error(PARAMETER_PROBLEM, 
-                                          "Line %u seems to have a "
-                                          " -t table option.\n", line);
-                               exit(1);
-                       }
-                       if (!strlen((char *) &curtable)) {
-                               exit_error(PARAMETER_PROBLEM,
-                                          "Line %u seems to to have a "
-                                          " zero-length table name.\n", line);
-                               exit(1);
-                       } 
                        
                         add_argv(argv[0]);
                         add_argv("-t");
@@ -358,6 +342,14 @@ int main(int argc, char *argv[])
                                         strncpy(param_buffer, param_start,
                                                 param_len);
                                         *(param_buffer+param_len) = '\0';
+
+                                       if (!strncmp(param_buffer, "-t", 3)) {
+                                               exit_error(PARAMETER_PROBLEM, 
+                                                  "Line %u seems to have a "
+                                                  "-t table option.\n", line);
+                                               exit(1);
+                                       }
+
                                         add_argv(param_buffer);
                                         param_start += param_len + 1;
                                 } else {
index a6e818e61634f1a56c4b9e6210eef3f02492fd8e..2a18a0950a49b8c8ac4d8e0b3b9bea40e650b70c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This coude is distributed under the terms of GNU GPL
  *
- * $Id: iptables-restore.c,v 1.15 2001/10/16 07:53:34 laforge Exp $
+ * $Id: iptables-restore.c,v 1.16 2001/10/16 09:51:33 laforge Exp $
  */
 
 #include <getopt.h>
@@ -81,6 +81,7 @@ static int newargc;
 /* function adding one argument to newargv, updating newargc 
  * returns true if argument added, false otherwise */
 static int add_argv(char *what) {
+       DEBUGP("add_argv: %s\n", what);
        if (what && ((newargc + 1) < sizeof(newargv)/sizeof(char *))) {
                newargv[newargc] = strdup(what);
                newargc++;
@@ -289,22 +290,6 @@ int main(int argc, char *argv[])
                                parsestart = buffer;
                        }
 
-                       /* prevent iptables-restore from crashing in do_command
-                        * when someone passes a "-t" on the line.
-                        *  - Ben Reser <ben@reser.org> */
-                       if (strstr(buffer, "-t")) {
-                               exit_error(PARAMETER_PROBLEM, 
-                                          "Line %u seems to have a "
-                                          " -t table option.\n", line);
-                               exit(1);
-                       }
-                       if (!strlen((char *) &curtable)) {
-                               exit_error(PARAMETER_PROBLEM,
-                                          "Line %u seems to to have a "
-                                          " zero-length table name.\n", line);
-                               exit(1);
-                       } 
-                       
                        add_argv(argv[0]);
                        add_argv("-t");
                        add_argv((char *) &curtable);
@@ -351,6 +336,15 @@ int main(int argc, char *argv[])
                                        strncpy(param_buffer, param_start,
                                                param_len);
                                        *(param_buffer+param_len) = '\0';
+
+                                       /* check if table name specified */
+                                       if (!strncmp(param_buffer, "-t", 3)) {
+                                               exit_error(PARAMETER_PROBLEM, 
+                                                  "Line %u seems to have a "
+                                                  "-t table option.\n", line);
+                                               exit(1);
+                                       }
+
                                        add_argv(param_buffer);
                                        param_start += param_len + 1;
                                } else {