On Mon, Jul 10, 2017 at 08:17:02AM -0700, Stephen Hemminger wrote: > On Mon, 10 Jul 2017 13:19:12 +0200 > Phil Sutter <p...@nwl.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