* Place NULL bytes at the end of strings so that
lxc_safe_ulong() can parse them correctly
* Only free the newly created id_map on error,
to avoid passing garbage to lxc_map_ids()
Signed-off-by: Cameron Nemo <camerontnorman@gmail.com>
{
size_t len;
char *p1, *p2;
{
size_t len;
char *p1, *p2;
+ unsigned long ul1, ul2;
FILE *fin;
int ret = -1;
size_t sz = 0;
FILE *fin;
int ret = -1;
size_t sz = 0;
- newmap = malloc(sizeof(*newmap));
- if (!newmap)
- goto on_error;
+ line[strlen(line) - 1] = '\0';
+ *p2 = '\0';
- ret = lxc_safe_ulong(p1 + 1, &newmap->hostid);
+ ret = lxc_safe_ulong(p1 + 1, &ul1);
- ret = lxc_safe_ulong(p2 + 1, &newmap->range);
+ ret = lxc_safe_ulong(p2 + 1, &ul2);
+ break;
+
+ ret = -1;
+ newmap = malloc(sizeof(*newmap));
+ if (!newmap)
+ break;
newmap->nsid = 0;
newmap->idtype = which;
newmap->nsid = 0;
newmap->idtype = which;
+ newmap->hostid = ul1;
+ newmap->range = ul2;
tmp = malloc(sizeof(*tmp));
tmp = malloc(sizeof(*tmp));
- if (!tmp)
- goto on_error;
+ if (!tmp) {
+ free(newmap);
+ break;
+ }
tmp->elem = newmap;
lxc_list_add_tail(&active_map, tmp);
tmp->elem = newmap;
lxc_list_add_tail(&active_map, tmp);