[lxc-devel] [PATCH] coverity: fix resource leak

Stéphane Graber stgraber at ubuntu.com
Fri Feb 14 15:08:46 UTC 2014


On Fri, Feb 14, 2014 at 09:49:51AM -0500, Dwight Engen wrote:
> also fix the check if the string will fit the local buffer
> 
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>

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

> ---
>  src/lxc/cgmanager.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index 41ba3d3..e4bd734 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -422,8 +422,10 @@ static inline bool cgm_create(void *hdata)
>  	tmp = lxc_string_replace("%n", d->name, d->cgroup_pattern);
>  	if (!tmp)
>  		return false;
> -	if (strlen(tmp) > MAXPATHLEN)
> +	if (strlen(tmp) >= MAXPATHLEN) {
> +		free(tmp);
>  		return false;
> +	}
>  	strcpy(result, tmp);
>  	baselen = strlen(result);
>  	free(tmp);
> -- 
> 1.8.5.3
> 
> _______________________________________________
> 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/20140214/25ba493c/attachment.pgp>


More information about the lxc-devel mailing list