From: Christian Brauner Date: Fri, 28 Oct 2016 17:41:42 +0000 (+0200) Subject: conf/ile: get ip prefix via lxc_safe_uint() X-Git-Tag: lxc-2.1.0~257^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c6333988f4b90cd81474e561d453046e27ac7ef;p=thirdparty%2Flxc.git conf/ile: get ip prefix via lxc_safe_uint() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.h b/src/lxc/conf.h index a0f0c3ebc..7fb8ae8e7 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -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 { diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 8f370f6cf..ab8ee9035 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -853,8 +853,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 @@ -952,7 +956,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)) {