iptables: Initiate defined table before working on it
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Thu, 10 Nov 2011 09:02:23 +0000 (11:02 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 14 Nov 2011 15:44:09 +0000 (16:44 +0100)
src/iptables.c

index f562f32..9d6a9e7 100644 (file)
@@ -1572,6 +1572,13 @@ static int iptables_command(int argc, char *argv[])
 
                case 't':
                        table_name = optarg;
+
+                       table = iptables_init(table_name);
+                       if (table == NULL) {
+                               ret = -EINVAL;
+                               goto out;
+                       }
+
                        break;
 
                case 1:
@@ -1662,13 +1669,14 @@ static int iptables_command(int argc, char *argv[])
                xt_t->final_check(xt_t->tflags);
 #endif
 
-       if (table_name == NULL)
+       if (table == NULL) {
                table_name = "filter";
 
-       table = iptables_init(table_name);
-       if (table == NULL) {
-               ret = -EINVAL;
-               goto out;
+               table = iptables_init(table_name);
+               if (table == NULL) {
+                       ret = -EINVAL;
+                       goto out;
+               }
        }
 
        if (delete_chain != NULL) {