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

Andrei Vagin avagin at virtuozzo.com
Mon Mar 13 13:34:47 PDT 2017


Applied, thanks!

On Fri, Mar 10, 2017 at 09:55:53AM +0000, Rodrigo Bruno wrote:
> Signed-off-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
> ---
>  criu/img-remote-proto.c | 6 ++++--
>  criu/img-remote.c       | 3 ++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c
> index c05b921..3346d04 100644
> --- a/criu/img-remote-proto.c
> +++ b/criu/img-remote-proto.c
> @@ -432,8 +432,10 @@ static struct rimage *new_remote_image(char *path, char *snapshot_id)
>  		return NULL;
>  	}
>  
> -	strncpy(rimg->path, path, PATHLEN);
> -	strncpy(rimg->snapshot_id, snapshot_id, PATHLEN);
> +	strncpy(rimg->path, path, PATHLEN -1 );
> +	rimg->path[PATHLEN - 1] = '\0';
> +	strncpy(rimg->snapshot_id, snapshot_id, PATHLEN - 1);
> +	rimg->snapshot_id[PATHLEN - 1] = '\0';
>  	rimg->size = 0;
>  	buf->nbytes = 0;
>  	INIT_LIST_HEAD(&(rimg->buf_head));
> diff --git a/criu/img-remote.c b/criu/img-remote.c
> index 337cb4a..c53217f 100644
> --- a/criu/img-remote.c
> +++ b/criu/img-remote.c
> @@ -39,7 +39,8 @@ struct snapshot *new_snapshot(char *snapshot_id)
>  		pr_perror("Failed to allocate snapshot structure");
>  		return NULL;
>  	}
> -	strncpy(s->snapshot_id, snapshot_id, PATHLEN);
> +	strncpy(s->snapshot_id, snapshot_id, PATHLEN - 1);
> +	s->snapshot_id[PATHLEN - 1]= '\0';
>  	return s;
>  }
>  
> -- 
> 1.9.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list