Commit 34cb65ce authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: handle a case when a source argument is empty (v2)

For example:
mount -t tmpfs "" test

v2: don't leak memory
Reported-by: 's avatarRoss Boucher <boucher@gmail.com>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 18034bb6
......@@ -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
......
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