]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
lz4: Add check for proper byte skipping
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 29 May 2026 15:34:46 +0000 (17:34 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 29 May 2026 16:02:04 +0000 (18:02 +0200)
Check if truncated input is detected while skipping data.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Makefile.am
libarchive/test/CMakeLists.txt
libarchive/test/test_read_filter_lz4_raw.c [new file with mode: 0644]
libarchive/test/test_read_filter_lz4_raw_skip.uu [new file with mode: 0644]

index 9d9a637a9797ec41a86ceeea2b89150aa63d3102..47c4075525fa24f0d92a337aa7ec1f00dcecf597 100644 (file)
@@ -472,6 +472,7 @@ libarchive_test_SOURCES= \
        libarchive/test/test_read_filter_grzip.c \
        libarchive/test/test_read_filter_gzip_recursive.c \
        libarchive/test/test_read_filter_lrzip.c \
+       libarchive/test/test_read_filter_lz4_raw.c \
        libarchive/test/test_read_filter_lzop.c \
        libarchive/test/test_read_filter_lzop_multiple_parts.c \
        libarchive/test/test_read_filter_program.c \
@@ -826,6 +827,7 @@ libarchive_test_EXTRA_DIST=\
        libarchive/test/test_read_filter_grzip.tar.grz.uu \
        libarchive/test/test_read_filter_gzip_recursive.gz.uu \
        libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
+       libarchive/test/test_read_filter_lz4_raw_skip.uu \
        libarchive/test/test_read_filter_lzop.tar.lzo.uu \
        libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
        libarchive/test/test_read_filter_uudecode_raw.uu \
index 6cd95ce00dfdee4136b12d81dcb369f3fc12b46b..c67e71f3d6a9ecc8b850a0ad4c65d4a0c433c1a5 100644 (file)
@@ -104,6 +104,7 @@ IF(ENABLE_TEST)
     test_read_filter_grzip.c
     test_read_filter_gzip_recursive.c
     test_read_filter_lrzip.c
+    test_read_filter_lz4_raw.c
     test_read_filter_lzop.c
     test_read_filter_lzop_multiple_parts.c
     test_read_filter_program.c
diff --git a/libarchive/test/test_read_filter_lz4_raw.c b/libarchive/test/test_read_filter_lz4_raw.c
new file mode 100644 (file)
index 0000000..9cbb561
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2026 Tobias Stoeckmann
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+DEFINE_TEST(test_read_filter_lz4_raw_skip)
+{
+       struct archive *a;
+
+       const char *name = "test_read_filter_lz4_raw_skip";
+
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
+       extract_reference_file(name);
+       assertEqualIntA(a, ARCHIVE_FATAL,
+           archive_read_open_filename(a, name, 200));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_filter_lz4_raw_skip.uu b/libarchive/test/test_read_filter_lz4_raw_skip.uu
new file mode 100644 (file)
index 0000000..aaff306
--- /dev/null
@@ -0,0 +1,4 @@
+begin 644 test_read_filter_lz4_raw_skip.uu
+<!")-&&1`IP$``(`*`````%+3R8%0*DT8_/___P``
+`
+end