Linux Netfilter development
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@comx.dk>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 1/3] iptables: Fix chain rename bug in libiptc.
Date: Mon, 23 Mar 2009 13:55:14 +0100	[thread overview]
Message-ID: <20090323125514.959.87191.stgit@localhost.localdomain> (raw)

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;


             reply	other threads:[~2009-03-23 13:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-23 12:55 Jesper Dangaard Brouer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090323125514.959.87191.stgit@localhost.localdomain \
    --to=hawk@comx.dk \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox