]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
lz4: Check XXH32_init result 3100/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 31 May 2026 15:41:41 +0000 (17:41 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 31 May 2026 15:41:41 +0000 (17:41 +0200)
The XXH32_init function allocates memory. Check if the allocation was
successful and return ARCHIVE_FATAL on error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_support_filter_lz4.c
libarchive/archive_write_add_filter_lz4.c

index acd7f515799774e25ab51a89d769e3aa556c5615..69a53b9e59b3341f657f7962b3d2710c9239a63a 100644 (file)
@@ -512,8 +512,11 @@ lz4_filter_read_descriptor(struct archive_read_filter *self)
        /* Make sure we have a large enough buffer for uncompressed data. */
        if (lz4_allocate_out_block(self) != ARCHIVE_OK)
                return (ARCHIVE_FATAL);
-       if (state->flags.stream_checksum)
+       if (state->flags.stream_checksum) {
                state->xxh32_state = __archive_xxhash.XXH32_init(0);
+               if (state->xxh32_state == NULL)
+                       return (ARCHIVE_FATAL);
+       }
 
        state->decoded_size = 0;
        /* Success */
index efc408e2a3f8d964bf4eeea32438ab083192249e..4b79d0a3916d6e0970389cda1df838d490e8bf30 100644 (file)
@@ -417,9 +417,11 @@ lz4_write_stream_descriptor(struct archive_write_filter *f)
        sd[5] = (data->block_maximum_size << 4);
        sd[6] = (__archive_xxhash.XXH32(&sd[4], 2, 0) >> 8) & 0xff;
        data->out += 7;
-       if (data->stream_checksum)
+       if (data->stream_checksum) {
                data->xxh32_state = __archive_xxhash.XXH32_init(0);
-       else
+               if (data->xxh32_state == NULL)
+                       return (ARCHIVE_FATAL);
+       } else
                data->xxh32_state = NULL;
        return (ARCHIVE_OK);
 }