]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Make sure mapped is always set in unzip
authorMark Wielaard <mark@klomp.org>
Sat, 22 Jun 2024 22:52:06 +0000 (00:52 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 22 Jun 2024 22:54:55 +0000 (00:54 +0200)
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

index 002afc4e916b91217072b51c218c7b4a16e8d50b..9c74abdafc191d08b3df9b9ac3c8047a709463d7 100644 (file)
@@ -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;
        }
     }