[lxc-devel] [PATCH 4/7] coverity: check return value of fcntl in usernsexec

Serge Hallyn serge.hallyn at ubuntu.com
Wed Feb 12 21:58:37 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/lxc_usernsexec.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxc_usernsexec.c b/src/lxc/lxc_usernsexec.c
> index b82bcf8..e40fa53 100644
> --- a/src/lxc/lxc_usernsexec.c
> +++ b/src/lxc/lxc_usernsexec.c
> @@ -69,13 +69,16 @@ static void opentty(const char * tty) {
>  
>  	fd = open(tty, O_RDWR | O_NONBLOCK);
>  	if (fd == -1) {
> -		printf("WARN: could not reopen tty: %s", strerror(errno));
> +		printf("WARN: could not reopen tty: %s\n", strerror(errno));
>  		return;
>  	}
>  
>  	flags = fcntl(fd, F_GETFL);
>  	flags &= ~O_NONBLOCK;
> -	fcntl(fd, F_SETFL, flags);
> +	if (fcntl(fd, F_SETFL, flags) < 0) {
> +		printf("WARN: could not set fd flags: %s\n", strerror(errno));
> +		return;
> +	}
>  
>  	for (i = 0; i < fd; i++)
>  		close(i);
> -- 
> 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