]> git.proxmox.com Git - mirror_lxc.git/commitdiff
another place where readlink to be null terminated
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)
I did this one change by reading the code
but did not tried to run it.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/start.c

index e9f4500e878f9d8e2960b3c7f341c14d84feefac..d4cadac81eaa3b1df6ac6df234bd693c928bf2d7 100644 (file)
@@ -336,10 +336,15 @@ static void remove_init_pid(const char *name, pid_t pid)
 static int fdname(int fd, char *name, size_t size)
 {
        char path[MAXPATHLEN];
+       ssize_t len;
 
        snprintf(path, MAXPATHLEN, "/proc/self/fd/%d", fd);
 
-       return readlink(path, name, size) < 0 ? -1 : 0;
+       len = readlink(path, name, size);
+       if (len >  0)
+               path[len] = '\0';
+
+       return (len <= 0) ? -1 : 0;
 }
 
 static int console_init(char *console, size_t size)