lib/route: potential memory leak in pktloc.c

In scneario, where file modification time is unchanged, code is returning 0
form read_pktlocs(). It causes memory leak for path variable.
Memory for this variable is allocated inside build_sysconf_path()
by asprintf() function.

http://lists.infradead.org/pipermail/libnl/2015-December/002079.html

Signed-off-by: Amit Khatri <amit.khatri@samsung.com>
Signed-off-by: Rahul Jain <rahul.jain@samsung.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Amit Khatri 2015-12-17 10:33:05 +05:30 committed by Thomas Haller
parent 67683efd1d
commit eccca1acfc

View File

@ -101,8 +101,10 @@ static int read_pktlocs(void)
/* if stat fails, just try to read the file */
if (stat(path, &st) == 0) {
/* Don't re-read file if file is unchanged */
if (last_read == st.st_mtime)
return 0;
if (last_read == st.st_mtime) {
err = 0;
goto errout;
}
}
NL_DBG(2, "Reading packet location file \"%s\"\n", path);