Commit 788731b3 authored by Thomas Jarosch's avatar Thomas Jarosch Committed by Stephen Hemminger

Fix unterminated readlink() buffer usage

Signed-off-by: default avatarThomas Jarosch <thomas.jarosch@intra2net.com>
parent 707f612c
...@@ -273,13 +273,19 @@ static void user_ent_hash_build(void) ...@@ -273,13 +273,19 @@ static void user_ent_hash_build(void)
unsigned int ino; unsigned int ino;
char lnk[64]; char lnk[64];
int fd; int fd;
ssize_t link_len;
if (sscanf(d1->d_name, "%d%c", &fd, &crap) != 1) if (sscanf(d1->d_name, "%d%c", &fd, &crap) != 1)
continue; continue;
sprintf(name+pos, "%d", fd); sprintf(name+pos, "%d", fd);
if (readlink(name, lnk, sizeof(lnk)-1) < 0 ||
strncmp(lnk, pattern, strlen(pattern))) link_len = readlink(name, lnk, sizeof(lnk)-1);
if (link_len == -1)
continue;
lnk[link_len] = '\0';
if (strncmp(lnk, pattern, strlen(pattern)))
continue; continue;
sscanf(lnk, "socket:[%u]", &ino); sscanf(lnk, "socket:[%u]", &ino);
......
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