[1/4] libdwfl: Make sure mapped is always set in unzip

Message ID 20240622235013.2071424-1-mark@klomp.org
State Committed
Headers
Series [1/4] libdwfl: Make sure mapped is always set in unzip |

Commit Message

Mark Wielaard June 22, 2024, 11:50 p.m. UTC
  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(+)
  

Comments

Mark Wielaard June 25, 2024, 8:18 p.m. UTC | #1
Hi,

On Sun, Jun 23, 2024 at 01:50:10AM +0200, Mark Wielaard wrote:
> Found by GCC14 -Wanalyzer-null-argument.

Aaron took a quick look on irc and said all 4 patches looked
reasonable. So I pushed them all to main now.

Cheers,

Mark
  

Patch

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;
 	}
     }