[lxc-devel] [PATCH 5/8] apparmor/attach: make sure buffer is NUL-terminated

Serge Hallyn serge.hallyn at ubuntu.com
Wed Aug 14 20:34:16 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
> Signed-off-by: Christian Seiler <christian at iwakd.de>

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

> ---
>  src/lxc/apparmor.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/apparmor.c b/src/lxc/apparmor.c
> index a2d6476..cb81464 100644
> --- a/src/lxc/apparmor.c
> +++ b/src/lxc/apparmor.c
> @@ -42,12 +42,13 @@ again:
>  	}
>  	sz += 1024;
>  	buf = realloc(buf, sz);
> +	memset(buf, 0, sz);
>  	if (!buf) {
>  		ERROR("out of memory");
>  		fclose(f);
>  		return NULL;
>  	}
> -	ret = fread(buf, 1, sz, f);
> +	ret = fread(buf, 1, sz - 1, f);
>  	fclose(f);
>  	if (ret >= sz)
>  		goto again;
> -- 
> 1.7.10.4
> 
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead. 
> Download for free and get started troubleshooting in minutes. 
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list