From: Serge Hallyn Date: Fri, 27 Jun 2014 18:51:33 +0000 (-0500) Subject: cgm_get: make sure @value is null-terminated X-Git-Tag: lxc-1.1.0.alpha1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=107090814711dbafa6047ead07c4dec17499a517;p=thirdparty%2Flxc.git cgm_get: make sure @value is null-terminated Previously this was done by strncpy, but now we just read the len bytes - not including \0 - from a pipe, so pre-fill @value with 0s to be safe. This fixes the python3 api_test failure. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c index d18ec2c01..c4f48e9ac 100644 --- a/src/lxc/cgmanager.c +++ b/src/lxc/cgmanager.c @@ -806,6 +806,7 @@ static int cgm_get(const char *filename, char *value, size_t len, const char *na close(p[0]); return newlen; } + memset(value, 0, len); if (newlen < 0) { // child is reporting an error close(p[0]); return -1;