[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170710081702.54cf6c8b@xeon-e3>
Date: Mon, 10 Jul 2017 08:17:02 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Phil Sutter <phil@....cc>
Cc: netdev@...r.kernel.org
Subject: Re: [iproute PATCH] ip netns: Make sure netns name is sane
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;
}
Powered by blists - more mailing lists