On 01/03/2013 05:00 PM, Serge Hallyn wrote: > Quoting Stéphane Graber ([email protected]): >> 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 <[email protected]> >> --- >> 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.
>>
>> cursor = strstr(addr, " ");
>> if (cursor) {
>> @@ -601,11 +601,13 @@ static int config_network_ipv4(const char *key, const
>> char *value,
>>
>> if (!inet_pton(AF_INET, addr, &inetdev->addr)) {
>> SYSERROR("invalid ipv4 address: %s", value);
>> + free(addr);
>> return -1;
>> }
>>
>> if (bcast && !inet_pton(AF_INET, bcast, &inetdev->bcast)) {
>> SYSERROR("invalid ipv4 broadcast address: %s", value);
>> + free(addr);
>> return -1;
>> }
>>
>> @@ -624,6 +626,7 @@ static int config_network_ipv4(const char *key, const
>> char *value,
>>
>> lxc_list_add(&netdev->ipv4, list);
>>
>> + free(addr);
>> return 0;
>> }
>>
>> @@ -693,7 +696,7 @@ static int config_network_ipv6(const char *key, const
>> char *value,
>> lxc_list_init(list);
>> list->elem = inet6dev;
>>
>> - valdup = strdupa(value);
>> + valdup = strdup(value);
>
> and here
>
>> inet6dev->prefix = 64;
>> slash = strstr(valdup, "/");
>> if (slash) {
>> @@ -702,13 +705,20 @@ static int config_network_ipv6(const char *key, const
>> char *value,
>> inet6dev->prefix = atoi(netmask);
>> }
>>
>> + if (!valdup) {
>> + ERROR("no address specified");
>> + return -1;
>> + }
>
> (this is too late :)
>
>> +
>> if (!inet_pton(AF_INET6, value, &inet6dev->addr)) {
>> SYSERROR("invalid ipv6 address: %s", value);
>> + free(valdup);
>> return -1;
>> }
>>
>> lxc_list_add(&netdev->ipv6, list);
>>
>> + free(valdup);
>> return 0;
>> }
>>
>> --
>> 1.8.0
>>
>>
>> ------------------------------------------------------------------------------
>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
>> MVPs and experts. ON SALE this month only -- learn more at:
>> http://p.sf.net/sfu/learnmore_122712
>> _______________________________________________
>> Lxc-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712
_______________________________________________ Lxc-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/lxc-devel
