[lxc-devel] [PATCH 4/6] coverity: Check return value of setenv

Serge Hallyn serge.hallyn at ubuntu.com
Sat Feb 15 00:01:21 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

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

> ---
>  src/lxc/attach.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/attach.c b/src/lxc/attach.c
> index 8782652..28cf916 100644
> --- a/src/lxc/attach.c
> +++ b/src/lxc/attach.c
> @@ -317,8 +317,10 @@ static int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char*
>  		if (extra_keep_store) {
>  			size_t i;
>  			for (i = 0; extra_keep[i]; i++) {
> -				if (extra_keep_store[i])
> -					setenv(extra_keep[i], extra_keep_store[i], 1);
> +				if (extra_keep_store[i]) {
> +					if (setenv(extra_keep[i], extra_keep_store[i], 1) < 0)
> +						SYSERROR("Unable to set environment variable");
> +				}
>  				free(extra_keep_store[i]);
>  			}
>  			free(extra_keep_store);
> -- 
> 1.9.rc1
> 
> _______________________________________________
> 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