All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Oliver Ford <ojford@gmail.com>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore
Date: Fri, 19 May 2017 12:38:25 +0200	[thread overview]
Message-ID: <20170519103825.GC28091@breakpoint.cc> (raw)
In-Reply-To: <CAGMVOdu7K-e2t9eU03er+GguG3WYHFwcxR68H+S+Ra6PQok+Yg@mail.gmail.com>

Oliver Ford <ojford@gmail.com> wrote:
> On Fri, May 19, 2017 at 11:04 AM, Florian Westphal <fw@strlen.de> wrote:
> > Oliver Ford <ojford@gmail.com> wrote:
> >> Filter a beginning '--t'. Because the getopt_long function allows abbreviations,
> >> any parameter beginning with '--t' will be treated as '--table'.
> >
> > No, thats not correct:
> > --t is treated as --table.
> > --tfoo is an invalid option.
> > --ttl is ttl.
> >
> > So this:
> >
> >> +                             || !strncmp(param_buffer, "--t", 3)) {
> >>                               xtables_error(PARAMETER_PROBLEM,
> >> +                                     "The -t option (seen in line %u) cannot be "
> >> +                                     "used in ip6tables-restore.\n", line);
> >
> > .. rejects rules like
> >
> > -A INPUT -m ttl --ttl 32
> 
> Would strncmp(param_buffer, "--ta", 4) work? I don't think there are
> any options that begin with --ta other than --table.

That won't catch '--t'.

It will also add trouble later if any module adds an option like --tap,
--tail, --target, etc.

Whats wrong with:

if ((param_buffer[0] == '-' && param_buffer[1] != '-' &&
     strchr(param_buffer, 't') ||
     (!strncmp(param_buffer, "--t", 3) &&
      !strncmp(param_buffer, "--table", strlen(param_buffer)))) {

?

  reply	other threads:[~2017-05-19 10:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19  9:54 [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore Oliver Ford
2017-05-19 10:04 ` Florian Westphal
2017-05-19 10:12   ` Oliver Ford
2017-05-19 10:38     ` Florian Westphal [this message]
2017-05-19 10:41       ` Oliver Ford
2017-05-19 11:24       ` Oliver Ford
2017-05-19 11:36         ` Florian Westphal
2017-05-19 12:03           ` Oliver Ford

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=20170519103825.GC28091@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 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.