]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf/ile: get ip prefix via lxc_safe_uint()
authorChristian Brauner <christian.brauner@canonical.com>
Fri, 28 Oct 2016 17:41:42 +0000 (19:41 +0200)
committerChristian Brauner <christian.brauner@canonical.com>
Tue, 22 Nov 2016 02:41:09 +0000 (03:41 +0100)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/conf.h
src/lxc/confile.c

index a0f0c3ebc487acd49ed7ce173e6a2bd20c548ea6..7fb8ae8e7f1e4c155bb9f7e86bac34d9bb573a6e 100644 (file)
@@ -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 {
index 8f370f6cfe43c86e2371ffca7db42fe6063d0377..ab8ee9035d3ec1a6b3b3edd46b20895d12d33384 100644 (file)
@@ -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)) {