From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 5/9] libxtables: fix memory scribble beyond end of array
Date: Sun, 27 Feb 2011 02:31:15 +0100 [thread overview]
Message-ID: <1298770280-7652-6-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1298770280-7652-1-git-send-email-jengelh@medozas.de>
When using -s "", the "n" variable in the code remains uninitialized
and usually scribbes beyond the end of the array.
Furthermore, "n" is just as big as entries in the last host lookup.
When specifying more than one item to -s, e.g. "-s host,host", "n" is
less than "count", and we are not masking the addresses at all
(leaving them at addr/32 resp. addr/128).
The issue goes back to the initial code from v1.4.5~21.
References: http://bugs.debian.org/611990
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
xtables.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/xtables.c b/xtables.c
index 57d5d13..f66fb27 100644
--- a/xtables.c
+++ b/xtables.c
@@ -1272,7 +1272,7 @@ void xtables_ipparse_multiple(const char *name, struct in_addr **addrpp,
free(addrp);
}
*naddrs = count;
- for (i = 0; i < n; ++i)
+ for (i = 0; i < count; ++i)
(*addrpp+i)->s_addr &= (*maskpp+i)->s_addr;
}
@@ -1587,7 +1587,7 @@ xtables_ip6parse_multiple(const char *name, struct in6_addr **addrpp,
free(addrp);
}
*naddrs = count;
- for (i = 0; i < n; ++i)
+ for (i = 0; i < count; ++i)
for (j = 0; j < 4; ++j)
(*addrpp+i)->s6_addr32[j] &= (*maskpp+i)->s6_addr32[j];
}
--
1.7.1
next prev parent reply other threads:[~2011-02-27 1:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-27 1:31 iptables: docs & address parsing Jan Engelhardt
2011-02-27 1:31 ` [PATCH 1/9] doc: mention other possible nf_loggers for TRACE Jan Engelhardt
2011-02-27 1:31 ` [PATCH 2/9] doc: fix odd partial sentence in libipt_TTL Jan Engelhardt
2011-02-27 1:31 ` [PATCH 3/9] libxt_quota: require --quota to be specified Jan Engelhardt
2011-02-27 1:31 ` [PATCH 4/9] doc: rateest options can be optional Jan Engelhardt
2011-02-27 1:31 ` Jan Engelhardt [this message]
2011-02-27 1:31 ` [PATCH 6/9] libxtables: avoid confusing use of ai_protocol=IPPROTO_IPV6 Jan Engelhardt
2011-02-27 1:31 ` [PATCH 7/9] xtables: fix excessive memory allocation in host_to_ipaddr Jan Engelhardt
2011-02-27 1:31 ` [PATCH 8/9] xtables: fix the broken detection/removal of redundant addresses Jan Engelhardt
2011-02-27 1:31 ` [PATCH 9/9] xtables: use all IPv6 addresses resolved from a hostname Jan Engelhardt
2011-02-27 15:19 ` iptables: docs & address parsing Patrick McHardy
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=1298770280-7652-6-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--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;
as well as URLs for NNTP newsgroup(s).