[lxc-devel] [PATCH] network.c:is_wlan() File Leak f f initialized at line 156 with fopen f leaks when fopen(path, r) != NULL at line 156 and physname == NULL at line 163.

Stéphane Graber stgraber at ubuntu.com
Mon Jan 4 17:50:53 UTC 2016


On Mon, Dec 28, 2015 at 10:23:47PM -0800, wim.coekaerts at oracle.com wrote:
> From: Wim Coekaerts <wim.coekaerts at oracle.com>
> 
> Signed-off-by: Wim Coekaerts <wim.coekaerts at oracle.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/network.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/lxc/network.c b/src/lxc/network.c
> index d4b015d..3417928 100644
> --- a/src/lxc/network.c
> +++ b/src/lxc/network.c
> @@ -160,8 +160,10 @@ static char * is_wlan(const char *ifname)
>  	physlen = ftell(f);
>  	fseek(f, 0, SEEK_SET);
>  	physname = malloc(physlen+1);
> -	if (!physname)
> +	if (!physname) {
> +		fclose(f);	
>  		goto bad;
> +	}
>  	memset(physname, 0, physlen+1);
>  	ret = fread(physname, 1, physlen, f);
>  	fclose(f);
> -- 
> 1.7.1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160104/90e3c1b1/attachment.sig>


More information about the lxc-devel mailing list