netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [iproute PATCH v2 4/5] tc/tc_filter: Make sure filter name is not empty
Date: Fri, 18 Aug 2017 18:57:05 +0200	[thread overview]
Message-ID: <20170818165705.GF16375@orbyte.nwl.cc> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD005AE0E@AcuExch.aculab.com>

On Fri, Aug 18, 2017 at 04:34:44PM +0000, David Laight wrote:
> From: Phil Sutter
> > Sent: 18 August 2017 12:16
> > On Fri, Aug 18, 2017 at 09:30:35AM +0000, David Laight wrote:
> > > From: Phil Sutter
> > > > Sent: 17 August 2017 18:10
> > > > The later check for 'k[0] != 0' requires a non-empty filter name,
> > > > otherwise NULL pointer dereference in 'q' might happen.
> > > >
> > > > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > > > ---
> > > >  tc/tc_filter.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/tc/tc_filter.c b/tc/tc_filter.c
> > > > index b13fb9185d4fd..a799edb35886d 100644
> > > > --- a/tc/tc_filter.c
> > > > +++ b/tc/tc_filter.c
> > > > @@ -412,6 +412,9 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
> > > >  			usage();
> > > >  			return 0;
> > > >  		} else {
> > > > +			if (!strlen(*argv))
> > > > +				invarg("invalid filter name", *argv);
> > >
> > > That is nearly as bad as:
> > > 	p[strlen(p)] = 0;
> > 
> > Hey, it's not impossible! I could call tc like so:
> > 
> > | # tc filter get protocol ip prio 1 ""
> 
> You missed the point. Just check **argv there is no need to
> determine the length just to check it is non-zero.

Oh, hehe. Thanks for the short-cut!

Thanks, PHil

  reply	other threads:[~2017-08-18 16:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 17:09 [iproute PATCH v2 0/5] Covscan: Fix potential NULL pointer dereferences Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 1/5] ifstat, nstat: Check fdopen() return value Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 2/5] nstat: Fix for potential NULL pointer dereference Phil Sutter
2017-08-18 16:28   ` Stephen Hemminger
2017-08-17 17:09 ` [iproute PATCH v2 3/5] tc/q_netem: Don't dereference possibly NULL pointer Phil Sutter
2017-08-18 16:25   ` Stephen Hemminger
2017-08-17 17:09 ` [iproute PATCH v2 4/5] tc/tc_filter: Make sure filter name is not empty Phil Sutter
2017-08-18  9:30   ` David Laight
2017-08-18 11:16     ` Phil Sutter
2017-08-18 16:34       ` David Laight
2017-08-18 16:57         ` Phil Sutter [this message]
2017-08-17 17:09 ` [iproute PATCH v2 5/5] tipc/bearer: Prevent NULL pointer dereference Phil Sutter
2017-08-18 16:24   ` Stephen Hemminger

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=20170818165705.GF16375@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=David.Laight@ACULAB.COM \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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).