All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] iptables: Fix chain rename bug in libiptc.
@ 2009-03-23 12:55 Jesper Dangaard Brouer
  2009-03-23 12:55 ` [PATCH 2/3] iptables: Fix whitespaces and typos Jesper Dangaard Brouer
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jesper Dangaard Brouer @ 2009-03-23 12:55 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

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>
---

 libiptc/libiptc.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index 544a5b2..86cfab4 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;


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-03-23 13:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 12:55 [PATCH 1/3] iptables: Fix chain rename bug in libiptc Jesper Dangaard Brouer
2009-03-23 12:55 ` [PATCH 2/3] iptables: Fix whitespaces and typos Jesper Dangaard Brouer
2009-03-23 13:27   ` Patrick McHardy
2009-03-23 12:55 ` [PATCH 3/3] iptables: libiptc give credits to my self Jesper Dangaard Brouer
2009-03-23 13:28   ` Patrick McHardy
2009-03-23 13:26 ` [PATCH 1/3] iptables: Fix chain rename bug in libiptc Patrick McHardy
2009-03-23 13:55   ` Jan Engelhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.