libpkgconf: path: ensure entire buffer is zeroed before calling realpath() on it (closes #150)

pull/164/head
William Pitcock 2017-10-16 11:25:52 -05:00
parent 6985a179c1
commit 3bc2e21dd1
1 changed files with 4 additions and 1 deletions

View File

@ -90,7 +90,10 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
if (S_ISLNK(st.st_mode)) if (S_ISLNK(st.st_mode))
{ {
char linkdest[PKGCONF_BUFSIZE]; char linkdest[PKGCONF_BUFSIZE];
ssize_t len = readlink(text, linkdest, sizeof(linkdest)); ssize_t len;
memset(linkdest, '\0', sizeof linkdest);
len = readlink(text, linkdest, sizeof linkdest);
if (len != -1 && (size_t)len < sizeof(linkdest) && if (len != -1 && (size_t)len < sizeof(linkdest) &&
stat(linkdest, &st) == -1) stat(linkdest, &st) == -1)