[CRIU] [PATCH 1/4] mount: handle a case when a source argument is empty (v2)
Andrey Vagin
avagin at openvz.org
Fri Jul 17 07:40:22 PDT 2015
For example:
mount -t tmpfs "" test
v2: don't leak memory
Reported-by: Ross Boucher <boucher at gmail.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
proc_parse.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/proc_parse.c b/proc_parse.c
index 5b26b32..1267f26 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -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
--
2.1.0
More information about the CRIU
mailing list