[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170712181253.GB16375@orbyte.nwl.cc>
Date: Wed, 12 Jul 2017 20:12:53 +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 Wed, Jul 12, 2017 at 09:38:34AM -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;
> > +}
>
> Looks like natural place to use strdupa.
>
> static bool is_basename(const char *name)
> {
> return strcmp(basename(strdupa(name), name) == 0;
> }
Good point! Anyway, my patch fails to cover 'ip netns del' command
(apart from the '..' issue), so I'd suggest to instead apply Matteo's
version (Message-ID 20170710120831.9355-1-mcroce@...hat.com).
Thanks, Phil
Powered by blists - more mailing lists