Skip to content

Commit

Permalink
confile: Don't crash on invalid id_map
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
stgraber committed Feb 25, 2014
1 parent 00903d7 commit 6f97095
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lxc/confile.c
Expand Up @@ -1300,24 +1300,25 @@ 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;
else if (type == 'g')
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:
Expand Down

0 comments on commit 6f97095

Please sign in to comment.