* [PATCH 1/1] iptables-xml: Fix segfault on jump without a target
@ 2017-06-02 15:34 Oliver Ford
2017-06-19 17:30 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Ford @ 2017-06-02 15:34 UTC (permalink / raw)
To: netfilter-devel; +Cc: Oliver Ford
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] iptables-xml: Fix segfault on jump without a target
2017-06-02 15:34 [PATCH 1/1] iptables-xml: Fix segfault on jump without a target Oliver Ford
@ 2017-06-19 17:30 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-06-19 17:30 UTC (permalink / raw)
To: Oliver Ford; +Cc: netfilter-devel
On Fri, Jun 02, 2017 at 03:34:37PM +0000, Oliver Ford wrote:
> 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.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-19 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-02 15:34 [PATCH 1/1] iptables-xml: Fix segfault on jump without a target Oliver Ford
2017-06-19 17:30 ` Pablo Neira Ayuso
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).