From: Florian Westphal <fw@strlen.de>
To: Oliver Ford <ojford@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [1/1] iptables: Fix crash on malformed iptables-restore
Date: Thu, 18 May 2017 00:19:39 +0200 [thread overview]
Message-ID: <20170517221939.GA1748@breakpoint.cc> (raw)
In-Reply-To: <1495039661-9178-1-git-send-email-ojford@gmail.com>
Oliver Ford <ojford@gmail.com> wrote:
> Fixes the crash reported in Bugzilla #1131 where a malformed
> parameter that specifies the table option can create an invalid
> pointer.
>
> Improves the tables option check to find a beginning '-' followed by
> a 't' anywhere in the parameter.
> diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
> index 876fe06..70dc7eb 100644
> --- a/iptables/iptables-restore.c
> +++ b/iptables/iptables-restore.c
> @@ -162,8 +162,7 @@ static void add_param_to_argv(char *parsestart)
> param_buffer[param_len] = '\0';
>
> /* check if table name specified */
> - if (!strncmp(param_buffer, "-t", 2)
> - || !strncmp(param_buffer, "--table", 8)) {
> + if (param_buffer[0] == '-' && strchr(param_buffer, 't')) {
> xtables_error(PARAMETER_PROBLEM,
> "The -t option (seen in line %u) cannot be "
> "used in iptables-restore.\n", line);
strchr() can only called if param_buffer[1] != '-', else this breaks
something like:
# Generated by iptables-save v1.6.0 on Thu May 18 00:00:38 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
--delete foo
COMMIT
(use '-n' option to iptables).
next prev parent reply other threads:[~2017-05-17 22:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-17 16:47 [PATCH 1/1] iptables: Fix crash on malformed iptables-restore Oliver Ford
2017-05-17 22:19 ` Florian Westphal [this message]
2017-05-18 9:33 ` [1/1] " Oliver Ford
2017-05-18 10:01 ` Florian Westphal
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=20170517221939.GA1748@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=ojford@gmail.com \
/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).