[lxc-devel] [PATCH] coverity 1097618: check for NULL return from calloc before deref

Stéphane Graber stgraber at ubuntu.com
Tue Oct 29 18:54:39 UTC 2013


On Tue, Oct 29, 2013 at 02:49:16PM -0400, Dwight Engen wrote:
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/cgroup.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index cf1605a..6aa4495 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -1688,6 +1688,8 @@ char *cgroup_to_absolute_path(struct cgroup_mount_point *mp, const char *path, c
>  
>  	len = strlen(mp->mount_point) + strlen(path) + (suffix ? strlen(suffix) : 0);
>  	buf = calloc(len + 1, 1);
> +	if (!buf)
> +		return NULL;
>  	rv = snprintf(buf, len + 1, "%s%s%s", mp->mount_point, path, suffix ? suffix : "");
>  	if (rv > len) {
>  		free(buf);
> -- 
> 1.8.3.1
> 
> 
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/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: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131029/681dede5/attachment.pgp>


More information about the lxc-devel mailing list