summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Khatri <amit.khatri@samsung.com>2015-12-17 05:03:05 (GMT)
committerThomas Haller <thaller@redhat.com>2015-12-18 07:43:19 (GMT)
commiteccca1acfc7242136256185746d93ec7bd10be82 (patch)
treed6b78cb785d7972fcc5e1c8b2631b3ad07e563b3
parent67683efd1d28d0d6525643236f78d6f9ad64db28 (diff)
downloadlibnl-eccca1acfc7242136256185746d93ec7bd10be82.zip
libnl-eccca1acfc7242136256185746d93ec7bd10be82.tar.gz
libnl-eccca1acfc7242136256185746d93ec7bd10be82.tar.bz2
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>
-rw-r--r--lib/route/pktloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c
index 27d63be..75d049e 100644
--- a/lib/route/pktloc.c
+++ b/lib/route/pktloc.c
@@ -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);