Commit 104b6a3a by Christian Brauner Committed by Stéphane Graber

conf/ile: get ip prefix via lxc_safe_uint()

parent f41ee3e0
......@@ -62,7 +62,7 @@ enum {
struct lxc_inetdev {
struct in_addr addr;
struct in_addr bcast;
int prefix;
unsigned int prefix;
};
struct lxc_route {
......@@ -80,7 +80,7 @@ struct lxc_inet6dev {
struct in6_addr addr;
struct in6_addr mcast;
struct in6_addr acast;
int prefix;
unsigned int prefix;
};
struct lxc_route6 {
......
......@@ -848,8 +848,12 @@ static int config_network_ipv4(const char *key, const char *value,
}
/* no prefix specified, determine it from the network class */
inetdev->prefix = prefix ? atoi(prefix) :
config_ip_prefix(&inetdev->addr);
if (prefix) {
if (lxc_safe_uint(prefix, &inetdev->prefix) < 0)
return -1;
} else {
inetdev->prefix = config_ip_prefix(&inetdev->addr);
}
/* if no broadcast address, let compute one from the
* prefix and address
......@@ -947,7 +951,8 @@ static int config_network_ipv6(const char *key, const char *value,
if (slash) {
*slash = '\0';
netmask = slash + 1;
inet6dev->prefix = atoi(netmask);
if (lxc_safe_uint(netmask, &inet6dev->prefix) < 0)
return -1;
}
if (!inet_pton(AF_INET6, valdup, &inet6dev->addr)) {
......
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