[lxc-devel] [PATCH 0/2] criu: DECLARE_ARG should check for null arguments

Serge Hallyn serge.hallyn at ubuntu.com
Wed Oct 8 17:34:57 UTC 2014


Quoting Tycho Andersen (tycho.andersen at canonical.com):
> This is in preparation for the cgroups creation work, but also probably just a
> good idea in general. The ERROR message is handy since we print line nos. it
> will to give people an indication of what arg was null.
> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>

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

> ---
>  src/lxc/lxccontainer.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 4f90f35..fee758d 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -3554,11 +3554,15 @@ static void exec_criu(struct criu_opts *opts)
>  
>  	memset(argv, 0, static_args * sizeof(*argv));
>  
> -#define DECLARE_ARG(arg) 			\
> -	do {					\
> -		argv[argc++] = strdup(arg);	\
> -		if (!argv[argc-1])		\
> -			goto err;		\
> +#define DECLARE_ARG(arg) 					\
> +	do {							\
> +		if (arg == NULL) {				\
> +			ERROR("Got NULL argument for criu");	\
> +			goto err;				\
> +		}						\
> +		argv[argc++] = strdup(arg);			\
> +		if (!argv[argc-1])				\
> +			goto err;				\
>  	} while (0)
>  
>  	argv[argc++] = on_path("criu", NULL);
> -- 
> 1.9.1
> 
> _______________________________________________
> 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