]> 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)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 22 Nov 2016 04:59:00 +0000 (23:59 -0500)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/conf.h
src/lxc/confile.c

index 523d58046eb4454c843c289e78cb36b71d7f7837..7aeba179c09275485801a33dd302ceb75731d6db 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;
 };
 
 #ifdef HAVE_TLS
index 2908da592dc1a30d2e77cc31027ad5da40c581fa..2abde727dafbdc3d888132d1e38ac4de2e48d959 100644 (file)
@@ -2955,13 +2955,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;