From 3bc2e21dd1e75643f6d0b81a26c408f058f37449 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 16 Oct 2017 11:25:52 -0500 Subject: [PATCH] libpkgconf: path: ensure entire buffer is zeroed before calling realpath() on it (closes #150) --- libpkgconf/path.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 5b7aa1c..d242759 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -90,7 +90,10 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) if (S_ISLNK(st.st_mode)) { 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) && stat(linkdest, &st) == -1)