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

Christian Seiler christian at iwakd.de
Tue Aug 13 21:56:17 UTC 2013


Signed-off-by: Christian Seiler <christian at iwakd.de>
---
 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





More information about the lxc-devel mailing list