From: Marcus Sundberg <marcus@ingate.com>
To: netfilter-devel@lists.netfilter.org
Subject: [PATCH] Avoid using freed memory in iptables.c
Date: Mon, 18 Jul 2005 17:53:37 +0200 [thread overview]
Message-ID: <42DBD081.8080408@ingate.com> (raw)
In-Reply-To: <42D90485.5050603@ingate.com>
Hi, resend in slighty more conformant(?) format:
The call to free_opts() in merge_options() is invalid C. The oldopts
argument always refers to the memory pointed to by the opts global,
which may be freed by the call to free_opts(), but oldopts is used
after the free_opts() call. This patch makes sure we don't use freed
memory.
Signed-off-by: Marcus Sundberg <marcus@ingate.com>
--- a/iptables.c 2005/07/16 12:52:33
+++ b/iptables.c 2005/07/16 12:52:45
@@ -1028,9 +1028,6 @@ merge_options(struct option *oldopts, co
unsigned int num_old, num_new, i;
struct option *merge;
- /* Release previous options merged if any */
- free_opts(0);
-
for (num_old = 0; oldopts[num_old].name; num_old++);
for (num_new = 0; newopts[num_new].name; num_new++);
@@ -1039,6 +1036,7 @@ merge_options(struct option *oldopts, co
merge = malloc(sizeof(struct option) * (num_new + num_old + 1));
memcpy(merge, oldopts, num_old * sizeof(struct option));
+ free_opts(0); /* Release previous options merged if any */
for (i = 0; i < num_new; i++) {
merge[num_old + i] = newopts[i];
merge[num_old + i].val += *option_offset;
--
---------------------------------------+--------------------------
Marcus Sundberg <marcus@ingate.com> | Firewalls with SIP & NAT
Software Developer, Ingate Systems AB | http://www.ingate.com/
next prev parent reply other threads:[~2005-07-18 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-10 15:05 [ANNOUNCE] Release of iptables-1.3.2 Netfilter Core Team
2005-07-16 12:58 ` Marcus Sundberg
2005-07-18 15:53 ` Marcus Sundberg [this message]
2005-07-29 13:09 ` [PATCH] Avoid using freed memory in iptables.c Harald Welte
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=42DBD081.8080408@ingate.com \
--to=marcus@ingate.com \
--cc=netfilter-devel@lists.netfilter.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 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.