[lxc-devel] [PATCH 16/21] Replace strdupa call by standard strdup

Serge Hallyn serge.hallyn at canonical.com
Thu Jan 3 22:48:37 UTC 2013


Quoting Stéphane Graber (stgraber at ubuntu.com):
> On 01/03/2013 05:00 PM, Serge Hallyn wrote:
> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> >> strdupa appears to only exist in the standard glibc but at least not in bionic.
> >> Replace the two strdupa calls we have by a standard strdup.
> >>
> >> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
> >> ---
> >>  src/lxc/confile.c | 14 ++++++++++++--
> >>  1 file changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/lxc/confile.c b/src/lxc/confile.c
> >> index 940f0a9..2737822 100644
> >> --- a/src/lxc/confile.c
> >> +++ b/src/lxc/confile.c
> >> @@ -580,7 +580,7 @@ static int config_network_ipv4(const char *key, const char *value,
> >>  	lxc_list_init(list);
> >>  	list->elem = inetdev;
> >>  
> >> -	addr = strdupa(value);
> >> +	addr = strdup(value);
> > 
> > Please do check for !addr here.  strstr(NULL, x) will segfault.
> 
> Ok. I assumed that strstr was somehow doing the right thing when the
> value was NULL as that's what we've been doing over and over again in
> that file :)
>
> I'll take a look and fix those two and possibly a few more then.

Thanks :)

-serge




More information about the lxc-devel mailing list