From: Michel Normand Date: Thu, 25 Jun 2009 09:10:40 +0000 (+0200) Subject: another place where readlink to be null terminated X-Git-Tag: lxc_0_6_3~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acc8694126c270f7d3a237f965304ec9f78a6c85;p=thirdparty%2Flxc.git another place where readlink to be null terminated I did this one change by reading the code but did not tried to run it. Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/start.c b/src/lxc/start.c index e9f4500e8..d4cadac81 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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)