Commit acc86941 by Michel Normand Committed by Daniel Lezcano

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: 's avatarMichel Normand <normand@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 2b4e286d
...@@ -336,10 +336,15 @@ static void remove_init_pid(const char *name, pid_t pid) ...@@ -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) static int fdname(int fd, char *name, size_t size)
{ {
char path[MAXPATHLEN]; char path[MAXPATHLEN];
ssize_t len;
snprintf(path, MAXPATHLEN, "/proc/self/fd/%d", fd); 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) static int console_init(char *console, size_t size)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment