[CRIU] [PATCH 1/4] mount: handle a case when a source argument is empty

Pavel Emelyanov xemul at parallels.com
Fri Jul 17 06:14:26 PDT 2015


On 07/17/2015 01:49 PM, Andrey Vagin wrote:
> For example:
> mount -t tmpfs "" test
> 
> Reported-by: Ross Boucher <boucher at gmail.com>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  proc_parse.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/proc_parse.c b/proc_parse.c
> index 5b26b32..fc2e371 100644
> --- a/proc_parse.c
> +++ b/proc_parse.c
> @@ -1024,8 +1024,16 @@ 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)
> -		goto err;
> +	if (ret != 3) {

In this case the fsname and new->source are filled with data, no need to
re-scanf them again.

> +		/* src may be empty */
> +		ret = sscanf(str, "%ms %ms", fsname, &opt);
> +		if (ret != 2)
> +			goto err;
> +		new->source = xstrdup("");
> +		if (new->source == NULL)
> +			goto err;
> +	}
> +
>  	/*
>  	 * The kernel reports "subtypes" sometimes and the valid
>  	 * type-vs-subtype delimiter is the dot symbol. We disregard
> 



More information about the CRIU mailing list