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>
{
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);
}