]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgm_get: make sure @value is null-terminated
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 27 Jun 2014 18:51:33 +0000 (13:51 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 27 Jun 2014 18:51:33 +0000 (13:51 -0500)
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 <serge.hallyn@ubuntu.com>
src/lxc/cgmanager.c

index d18ec2c01aa84151d8603e7da1c505bebefc94d8..c4f48e9ac7b5f11be565b54a58ddd675c3f7ef0c 100644 (file)
@@ -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;