[lxc-devel] [PATCH 1/1] cgmanager: cgm_get: len = 0 is a query for length only

Serge Hallyn serge.hallyn at ubuntu.com
Mon Apr 7 17:52:43 UTC 2014


The caller might (like lxc-test-startone does) pass in a valid
(or invalid) buffer and 0 length.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/cgmanager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
index 8a5039a..1dea824 100644
--- a/src/lxc/cgmanager.c
+++ b/src/lxc/cgmanager.c
@@ -689,7 +689,7 @@ static int cgm_get(const char *filename, char *value, size_t len, const char *na
 	cgm_dbus_disconnect();
 	free(cgroup);
 	newlen = strlen(result);
-	if (!value) {
+	if (!len || !value) {
 		// user queries the size
 		nih_free(result);
 		return newlen+1;
-- 
1.9.1



More information about the lxc-devel mailing list