]> git.proxmox.com Git - mirror_lxc.git/commitdiff
the lxc_unlink_nsgroup may fail on ppc. V2
authorMichel Normand <normand@fr.ibm.com>
Thu, 25 Jun 2009 09:10:40 +0000 (11:10 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 25 Jun 2009 09:10:40 +0000 (11:10 +0200)
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 <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/cgroup.c

index 75d1a5301ac46cffa85409322498bef3827be6b5..a905899a9b7ebc1bac41925659000532dc2214ef 100644 (file)
@@ -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);
 }