Commit 394096b1 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files-reg: Sanitize rlb and rlb->path malloc/rollback code flow

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5552f9e7
......@@ -457,20 +457,23 @@ static int create_link_remap(char *path, int len, int lfd,
* we keep all data in memory.
*/
rlb = xmalloc(sizeof(*rlb));
if (rlb)
rlb->path = strdup(link_name);
if (!rlb)
goto err1;
if (!rlb || !rlb->path) {
pr_perror("Can't register rollback for %s", path);
xfree(rlb ? rlb->path : NULL);
xfree(rlb);
return -1;
}
rlb->path = strdup(link_name);
if (!rlb->path)
goto err2;
rlb->mnt_ns = nsid;
list_add(&rlb->list, &link_remaps);
return pb_write_one(fdset_fd(glob_fdset, CR_FD_REG_FILES), &rfe, PB_REG_FILE);
err2:
xfree(rlb);
err1:
pr_perror("Can't register rollback for %s", path);
return -1;
}
static int dump_linked_remap(char *path, int len, const struct stat *ost,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment