[lxc-devel] [PATCH] Check return value of snprintf

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 28 03:50:36 UTC 2015


Quoting Christian Brauner (christianvanbrauner at gmail.com):
> Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>
> ---

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

>  src/lxc/lxc_destroy.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/lxc/lxc_destroy.c b/src/lxc/lxc_destroy.c
> index 39e289c..0eeff51 100644
> --- a/src/lxc/lxc_destroy.c
> +++ b/src/lxc/lxc_destroy.c
> @@ -152,6 +152,8 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
>  
>  	/* Destroy snapshots created with lxc-clone listed in lxc-snapshots. */
>  	ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
> +	if (ret < 0 || ret >= MAXPATHLEN)
> +		return -1;
>  
>  	fd = open(path, O_RDONLY | O_CLOEXEC);
>  	if (fd >= 0) {
> -- 
> 2.5.3
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list