]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf/ile: avoid atoi() in config_ephemeral()
authorChristian Brauner <christian.brauner@canonical.com>
Fri, 28 Oct 2016 18:24:17 +0000 (20:24 +0200)
committerChristian Brauner <christian.brauner@canonical.com>
Tue, 22 Nov 2016 03:43:02 +0000 (04:43 +0100)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/conf.h
src/lxc/confile.c

index 283042c782b7bfdaadcbb894040f6f90d0ae8d2a..ae29d42103cc8fa054bc832db14f3e652c7422ef 100644 (file)
@@ -377,7 +377,7 @@ struct lxc_conf {
        gid_t init_gid;
 
        /* indicator if the container will be destroyed on shutdown */
-       int ephemeral;
+       unsigned int ephemeral;
 
        /* The facility to pass to syslog. Let's users establish as what type of
         * program liblxc is supposed to write to the syslog. */
index dad7a73f3581926354ba9c0938d3eb92fe4f7603..eccdcb54ca6d661bf0ed8f0787e20f68f7f860f5 100644 (file)
@@ -2964,13 +2964,12 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
 static int config_ephemeral(const char *key, const char *value,
                            struct lxc_conf *lxc_conf)
 {
-       int v = atoi(value);
+       if (lxc_safe_uint(value, &lxc_conf->ephemeral) < 0)
+               return -1;
 
-       if (v != 0 && v != 1) {
+       if (lxc_conf->ephemeral > 1) {
                ERROR("Wrong value for lxc.ephemeral. Can only be set to 0 or 1");
                return -1;
-       } else {
-               lxc_conf->ephemeral = v;
        }
 
        return 0;