mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
mount: handle a case when a source argument is empty (v2)
For example: mount -t tmpfs "" test v2: don't leak memory Reported-by: Ross Boucher <boucher@gmail.com> Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
18034bb642
commit
34cb65ce5d
@@ -1024,8 +1024,15 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
|
||||
|
||||
str += n;
|
||||
ret = sscanf(str, "%ms %ms %ms", fsname, &new->source, &opt);
|
||||
if (ret != 3)
|
||||
if (ret == 2) {
|
||||
/* src may be empty */
|
||||
opt = new->source;
|
||||
new->source = xstrdup("");
|
||||
if (new->source == NULL)
|
||||
goto err;
|
||||
} else if (ret != 3)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* The kernel reports "subtypes" sometimes and the valid
|
||||
* type-vs-subtype delimiter is the dot symbol. We disregard
|
||||
|
Reference in New Issue
Block a user