[CRIU] [PATCH v3] Fixed NULL_RETURNS issues introduced by remote images code.

Andrei Vagin avagin at virtuozzo.com
Mon Mar 20 12:18:05 PDT 2017


Applied with a few fixes. Thanks!

On Sat, Mar 18, 2017 at 05:51:37PM +0000, rodrigo-bruno wrote:
> Signed-off-by: rodrigo-bruno <rbruno at gsd.inesc-id.pt>
> ---
>  criu/image.c | 11 ++++++++---
>  criu/util.c  |  5 +++++
>  2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/image.c b/criu/image.c
> index 57d3c7b..0cbfbf7 100644
> --- a/criu/image.c
> +++ b/criu/image.c
> @@ -332,9 +332,14 @@ int do_open_remote_image(int dfd, char *path, int flags)
>  	/* When using namespaces, the current dir is changed so we need to
>  	 * change to previous working dir and back to correctly open the image
>  	 * proxy and cache sockets. */
> -	int save = dirfd(opendir("."));
> +	int save = open(".", O_RDONLY);
> +	if (save < 0) {
> +		pr_perror("unable to open current working directory");
> +		return -1;
> +	}
> +
>  	if (fchdir(get_service_fd(IMG_FD_OFF)) < 0) {
> -		pr_debug("fchdir to dfd failed!\n");
> +		pr_perror("fchdir to dfd failed!\n");
>  		return -1;
>  	}
>  
> @@ -353,7 +358,7 @@ int do_open_remote_image(int dfd, char *path, int flags)
>  	}
>  
>  	if (fchdir(save) < 0) {
> -		pr_debug("fchdir to save failed!\n");
> +		pr_perror("fchdir to save failed");
>  		return -1;
>  	}
>  	close(save);
> diff --git a/criu/util.c b/criu/util.c
> index 9fd8ba2..4156bf2 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -522,6 +522,11 @@ int copy_file(int fd_in, int fd_out, size_t bytes)
>  	char *buffer = (char*) malloc(chunk);
>  	ssize_t ret;
>  
> +	if (buffer == NULL) {
> +		pr_perror("failed to allocate buffer to copy file");
> +		return -1;
> +	}
> +
>  	while (1) {
>  		if (opts.remote) {
>  			ret = read(fd_in, buffer, chunk);
> -- 
> 2.1.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list