public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: Fix memory leak in unzip()
@ 2023-04-28  6:04 John Gallagher
  2023-05-08 16:12 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: John Gallagher @ 2023-04-28  6:04 UTC (permalink / raw)
  To: elfutils-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libdwfl: Fix memory leak in unzip()
  2023-04-28  6:04 [PATCH] libdwfl: Fix memory leak in unzip() John Gallagher
@ 2023-05-08 16:12 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2023-05-08 16:12 UTC (permalink / raw)
  To: John Gallagher, elfutils-devel

Hi John,

On Thu, 2023-04-27 at 23:04 -0700, John Gallagher wrote:
> state.input_buffer is not freed if the file is found to not be
> compressed with the compression algorithm unzip() is trying to use.

Thanks, pushed. It is clearly correct to call fail here.
Although in all my tests input_buffer was always NULL.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-08 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28  6:04 [PATCH] libdwfl: Fix memory leak in unzip() John Gallagher
2023-05-08 16:12 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).