Commit 956edc54 by Stéphane Graber

Replace strdupa call by standard strdup

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent da9dd0f1
...@@ -580,7 +580,11 @@ static int config_network_ipv4(const char *key, const char *value, ...@@ -580,7 +580,11 @@ static int config_network_ipv4(const char *key, const char *value,
lxc_list_init(list); lxc_list_init(list);
list->elem = inetdev; list->elem = inetdev;
addr = strdupa(value); addr = strdup(value);
if (!addr) {
ERROR("no address specified");
return -1;
}
cursor = strstr(addr, " "); cursor = strstr(addr, " ");
if (cursor) { if (cursor) {
...@@ -594,18 +598,15 @@ static int config_network_ipv4(const char *key, const char *value, ...@@ -594,18 +598,15 @@ static int config_network_ipv4(const char *key, const char *value,
prefix = slash + 1; prefix = slash + 1;
} }
if (!addr) {
ERROR("no address specified");
return -1;
}
if (!inet_pton(AF_INET, addr, &inetdev->addr)) { if (!inet_pton(AF_INET, addr, &inetdev->addr)) {
SYSERROR("invalid ipv4 address: %s", value); SYSERROR("invalid ipv4 address: %s", value);
free(addr);
return -1; return -1;
} }
if (bcast && !inet_pton(AF_INET, bcast, &inetdev->bcast)) { if (bcast && !inet_pton(AF_INET, bcast, &inetdev->bcast)) {
SYSERROR("invalid ipv4 broadcast address: %s", value); SYSERROR("invalid ipv4 broadcast address: %s", value);
free(addr);
return -1; return -1;
} }
...@@ -624,6 +625,7 @@ static int config_network_ipv4(const char *key, const char *value, ...@@ -624,6 +625,7 @@ static int config_network_ipv4(const char *key, const char *value,
lxc_list_add(&netdev->ipv4, list); lxc_list_add(&netdev->ipv4, list);
free(addr);
return 0; return 0;
} }
...@@ -693,7 +695,12 @@ static int config_network_ipv6(const char *key, const char *value, ...@@ -693,7 +695,12 @@ static int config_network_ipv6(const char *key, const char *value,
lxc_list_init(list); lxc_list_init(list);
list->elem = inet6dev; list->elem = inet6dev;
valdup = strdupa(value); valdup = strdup(value);
if (!valdup) {
ERROR("no address specified");
return -1;
}
inet6dev->prefix = 64; inet6dev->prefix = 64;
slash = strstr(valdup, "/"); slash = strstr(valdup, "/");
if (slash) { if (slash) {
...@@ -704,11 +711,13 @@ static int config_network_ipv6(const char *key, const char *value, ...@@ -704,11 +711,13 @@ static int config_network_ipv6(const char *key, const char *value,
if (!inet_pton(AF_INET6, value, &inet6dev->addr)) { if (!inet_pton(AF_INET6, value, &inet6dev->addr)) {
SYSERROR("invalid ipv6 address: %s", value); SYSERROR("invalid ipv6 address: %s", value);
free(valdup);
return -1; return -1;
} }
lxc_list_add(&netdev->ipv6, list); lxc_list_add(&netdev->ipv6, list);
free(valdup);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment