From: Oliver Ford <ojford@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Oliver Ford <ojford@gmail.com>
Subject: [PATCH 1/1] iptables-xml: Fix segfault on jump without a target
Date: Fri, 2 Jun 2017 15:34:37 +0000 [thread overview]
Message-ID: <1496417677-8228-1-git-send-email-ojford@gmail.com> (raw)
As reported in Bugzilla #1152, a segfault occurs in iptables-xml if a
jump or goto argument lacks a target argument. The following input will
segfault:
*filter
:INPUT ACCEPT [0:0]
-A INPUT -p tcp --dport 2200 -j
Problem occurs in do_rule_part, where the existsChain() function is called
with argv[arg + 1]. If the jump/goto argument is the last argument, then
arg + 1 is out of the array bounds. The fix ensures that arg + 1 is within
the array bounds before the call to existsChain() is made.
Signed-off-by: Oliver Ford <ojford@gmail.com>
---
iptables/iptables-xml.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c
index 56b8372..80de2de 100644
--- a/iptables/iptables-xml.c
+++ b/iptables/iptables-xml.c
@@ -427,11 +427,8 @@ do_rule_part(char *leveltag1, char *leveltag2, int part, int argc,
printf("%s%s", spacer, argv[arg]);
spacer = " ";
} else if (!argvattr[arg] && isTarget(argv[arg])
- && existsChain(argv[arg + 1])
- && (2 + arg >= argc)) {
- if (!((1 + arg) < argc))
- // no args to -j, -m or -g, ignore & finish loop
- break;
+ && (arg + 1 < argc)
+ && existsChain(argv[arg + 1])) {
CLOSE_LEVEL(2);
if (level1)
printf("%s", leveli1);
--
2.11.0
next reply other threads:[~2017-06-02 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 15:34 Oliver Ford [this message]
2017-06-19 17:30 ` [PATCH 1/1] iptables-xml: Fix segfault on jump without a target Pablo Neira Ayuso
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=1496417677-8228-1-git-send-email-ojford@gmail.com \
--to=ojford@gmail.com \
--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).