From: Michel Normand Date: Thu, 25 Jun 2009 09:10:40 +0000 (+0200) Subject: the lxc_unlink_nsgroup may fail on ppc. V2 X-Git-Tag: lxc_0_6_3~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b4e286d251f0add75a23c57ba361c326d945c10;p=thirdparty%2Flxc.git the lxc_unlink_nsgroup may fail on ppc. V2 the lxc_unlink_nsgroup may fail on ppc where the stack is not zeroed by default and because the readlink function do not add trailing null character. Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index 75d1a5301..a905899a9 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -114,11 +114,15 @@ int lxc_unlink_nsgroup(const char *name) { char nsgroup[MAXPATHLEN]; char path[MAXPATHLEN]; + ssize_t len; snprintf(nsgroup, MAXPATHLEN, LXCPATH "/%s/nsgroup", name); - if (readlink(nsgroup, path, MAXPATHLEN) > 0) + len = readlink(nsgroup, path, MAXPATHLEN-1); + if (len > 0) { + path[len] = '\0'; rmdir(path); + } return unlink(nsgroup); }