iptables: Fix rule insertion in a builtin chain
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Mon, 6 Feb 2012 13:24:22 +0000 (15:24 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 13 Feb 2012 11:57:34 +0000 (12:57 +0100)
src/iptables.c

index ed52bf2..80f63ec 100644 (file)
@@ -696,7 +696,10 @@ static int iptables_insert_rule(struct connman_iptables *table,
        if (new_entry == NULL)
                return -EINVAL;
 
-       ret = iptables_add_entry(table, new_entry, chain_head->next, builtin);
+       if (builtin == -1)
+               chain_head = chain_head->next;
+
+       ret = iptables_add_entry(table, new_entry, chain_head, builtin);
        if (ret < 0)
                g_free(new_entry);