]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: Don't crash on invalid id_map
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 25 Feb 2014 21:26:48 +0000 (16:26 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 25 Feb 2014 22:09:49 +0000 (17:09 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/confile.c

index afc9e32cdd978e1187a74a0891623d48b492b773..8b1c0b6e535b641f6ae58eb6d8b320bd120f4ada 100644 (file)
@@ -1300,13 +1300,10 @@ static int config_idmap(const char *key, const char *value, struct lxc_conf *lxc
                goto out;
        memset(idmap, 0, sizeof(*idmap));
 
-       idmaplist->elem = idmap;
-
-       lxc_list_add_tail(&lxc_conf->id_map, idmaplist);
-
        ret = sscanf(value, "%c %lu %lu %lu", &type, &nsid, &hostid, &range);
        if (ret != 4)
                goto out;
+
        INFO("read uid map: type %c nsid %lu hostid %lu range %lu", type, nsid, hostid, range);
        if (type == 'u')
                idmap->idtype = ID_TYPE_UID;
@@ -1314,10 +1311,14 @@ static int config_idmap(const char *key, const char *value, struct lxc_conf *lxc
                idmap->idtype = ID_TYPE_GID;
        else
                goto out;
+
        idmap->hostid = hostid;
        idmap->nsid = nsid;
        idmap->range = range;
 
+       idmaplist->elem = idmap;
+       lxc_list_add_tail(&lxc_conf->id_map, idmaplist);
+
        return 0;
 
 out: