btrfs-progs: subvolume create: handle failure for strdup()
The function strdup() can return NULL if the system is out of memory, thus we need to hanle the rare but possible -ENOMEM case. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
69a3871fdd
commit
943a69ef2d
|
@ -194,8 +194,17 @@ static int cmd_subvolume_create(const struct cmd_struct *cmd, int argc, char **a
|
|||
}
|
||||
|
||||
dupname = strdup(dst);
|
||||
if (!dupname) {
|
||||
error_msg(ERROR_MSG_MEMORY, "duplicating %s", dst);
|
||||
goto out;
|
||||
}
|
||||
newname = basename(dupname);
|
||||
|
||||
dupdir = strdup(dst);
|
||||
if (!dupdir) {
|
||||
error_msg(ERROR_MSG_MEMORY, "duplicating %s", dst);
|
||||
goto out;
|
||||
}
|
||||
dstdir = dirname(dupdir);
|
||||
|
||||
if (!test_issubvolname(newname)) {
|
||||
|
|
Loading…
Reference in New Issue