summaryrefslogtreecommitdiffstats
path: root/libiptc
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <hawk@comx.dk>2009-03-23 14:25:49 +0100
committerPatrick McHardy <kaber@trash.net>2009-03-23 14:25:49 +0100
commit64ff47cde38e48b621883947fd61b9b1357f9451 (patch)
tree369bc8b138bfdbd4c330d742c6f58de11442e656 /libiptc
parent7cd15e367cc81c839ef2ca061d201c46ca1deb7c (diff)
libiptc: fix chain rename bug in libiptc
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>
Diffstat (limited to 'libiptc')
-rw-r--r--libiptc/libiptc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index c3d9bfc8..6b3a1fbe 100644
--- a/libiptc/libiptc.c
+++ b/libiptc/libiptc.c
@@ -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;