[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170712123822.GU16375@orbyte.nwl.cc>
Date: Wed, 12 Jul 2017 14:38:22 +0200
From: Phil Sutter <phil@....cc>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [iproute PATCH] ip netns: Make sure netns name is sane
On Mon, Jul 10, 2017 at 08:17:02AM -0700, Stephen Hemminger wrote:
> On Mon, 10 Jul 2017 13:19:12 +0200
> Phil Sutter <phil@....cc> wrote:
>
> > +static bool is_basename(const char *name)
> > +{
> > + char *name_dup = strdup(name);
> > + bool rc = true;
> > +
> > + if (!name_dup)
> > + return false;
> > +
> > + if (strcmp(basename(name_dup), name))
> > + rc = false;
> > +
> > + free(name_dup);
> > + return rc;
> > +}
>
> Why not just:
>
> static bool is_basename(const char *name)
> {
> return strchr(name '/') == NULL;
> }
This is not sufficient since it doesn't cover netns names of '..' and
'.', as Matteo correctly pointed out.
Cheers, Phil
Powered by blists - more mailing lists