public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] libdwfl: Make sure mapped is always set in unzip
@ 2024-06-22 23:50 Mark Wielaard
  2024-06-22 23:50 ` [PATCH 2/4] libelf: elf32_getshdr might leak section header when out of memory Mark Wielaard
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mark Wielaard @ 2024-06-22 23:50 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

Found by GCC14 -Wanalyzer-null-argument.

When unzip is called with mapped NULL, but *_whole not NULL, *_whole
contains the first part of the input. But we check against mapped to
make sure the MAGIC bytes are there.

This only worked because this code path was never taken, unzip is
currently always called with *_whole being NULL.

	  * libdwfl/gzip.c (unzip): Set mapped = state.input_buffer
          when *whole is not NULL.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/gzip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c
index 002afc4e916b..9c74abdafc19 100644
--- a/libdwfl/gzip.c
+++ b/libdwfl/gzip.c
@@ -212,6 +212,7 @@ unzip (int fd, off_t start_offset,
       else
 	{
 	  state.input_buffer = *state.whole;
+	  mapped = state.input_buffer;
 	  state.input_pos = state.mapped_size = *whole_size;
 	}
     }
-- 
2.45.2


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

end of thread, other threads:[~2024-06-25 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-22 23:50 [PATCH 1/4] libdwfl: Make sure mapped is always set in unzip Mark Wielaard
2024-06-22 23:50 ` [PATCH 2/4] libelf: elf32_getshdr might leak section header when out of memory Mark Wielaard
2024-06-22 23:50 ` [PATCH 3/4] debuginfod-client: Don't leak id/version with duplicate os-release entries Mark Wielaard
2024-06-22 23:50 ` [PATCH 4/4] ar, ranlib: Don't double close file descriptors Mark Wielaard
2024-06-25 20:18 ` [PATCH 1/4] libdwfl: Make sure mapped is always set in unzip 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).