From 7e60c3f0c1ed21d2d47bc39e1abc7972714b435d Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Graber?= Date: Tue, 25 Feb 2014 16:26:48 -0500 Subject: [PATCH] confile: Don't crash on invalid id_map MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- src/lxc/confile.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lxc/confile.c b/src/lxc/confile.c index afc9e32cd..8b1c0b6e5 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -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: -- 2.47.2