]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libiptc: fix chain rename bug in libiptc
authorJesper Dangaard Brouer <hawk@comx.dk>
Mon, 23 Mar 2009 13:25:49 +0000 (14:25 +0100)
committerPatrick McHardy <kaber@trash.net>
Mon, 23 Mar 2009 13:25:49 +0000 (14:25 +0100)
Chain renaming (TC_RENAME_CHAIN) can result in an unsorted
chain list.  That breaks the requirement of the binary search
done in iptcc_bsearch_chain_index().

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
Signed-off-by: Patrick McHardy <kaber@trash.net>
libiptc/libiptc.c

index c3d9bfc876b7a0b9c9d8cd95edca128dbb1fcc51..6b3a1fbe979e06ab972b5dab22b039d2c11e8477 100644 (file)
@@ -2404,8 +2404,15 @@ int TC_RENAME_CHAIN(const IPT_CHAINLABEL oldname,
                return 0;
        }
 
+       /* This only unlinks "c" from the list, thus no free(c) */
+       iptcc_chain_index_delete_chain(c, handle);
+
+       /* Change the name of the chain */
        strncpy(c->name, newname, sizeof(IPT_CHAINLABEL));
-       
+
+       /* Insert sorted into to list again */
+       iptc_insert_chain(handle, c);
+
        set_changed(handle);
 
        return 1;