[PATCH] libdwfl: Fix memory leak in unzip()

John Gallagher john@gllghr.com
Fri Apr 28 06:04:31 GMT 2023


state.input_buffer is not freed if the file is found to not be
compressed with the compression algorithm unzip() is trying to use.

Signed-off-by: John Gallagher <john@gllghr.com>
---
 libdwfl/ChangeLog | 4 ++++
 libdwfl/gzip.c    | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index daef2828..54d85921 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2023-04-24  John Gallagher  <john@gllghr.com>
+
+	* gzip.c: Fix memory leak in unzip()
+
 2023-02-06  Mark Wielaard  <mark@klomp.org>
 
 	* libdwfl.h: Guard debuginfod_client typedef with
diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c
index 53013be3..002afc4e 100644
--- a/libdwfl/gzip.c
+++ b/libdwfl/gzip.c
@@ -227,7 +227,7 @@ unzip (int fd, off_t start_offset,
 #endif
       )
     /* Not a compressed file.  */
-    return DWFL_E_BADELF;
+    return fail (&state, DWFL_E_BADELF);
 
 #ifdef ZSTD
   /* special case for libzstd since it is slightly different from the
-- 
2.40.0



More information about the Elfutils-devel mailing list