]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
lz4: Detect truncation in lz4_filter_read 3093/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 28 May 2026 15:43:32 +0000 (17:43 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 29 May 2026 16:02:09 +0000 (18:02 +0200)
If __archive_read_filter_consume fails, report information about
detected truncation.

In many cases, the return value can be ignored since
__archive_read_ahead already performed the check. In this case, we never
read the data before, so add the check here.

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

index 517e73feb5a0026996634392583e66e4ec4d3961..b405e10fef3c82c59129752b8817bf1a97757459 100644 (file)
@@ -409,8 +409,14 @@ lz4_filter_read(struct archive_read_filter *self, const void **p)
                                return (ARCHIVE_FATAL);
                        }
                        int64_t skip_bytes = archive_le32dec(read_buf);
-                       __archive_read_filter_consume(self->upstream,
-                               4 + skip_bytes);
+                       if (__archive_read_filter_consume(self->upstream,
+                           4 + skip_bytes) < 0) {
+                               archive_set_error(
+                                   &self->archive->archive,
+                                   ARCHIVE_ERRNO_MISC,
+                                   "Malformed lz4 data");
+                               return (ARCHIVE_FATAL);
+                       }
                } else {
                        /* Ignore following unrecognized data. */
                        state->eof = 1;