1
0
mirror of https://git.tukaani.org/xz.git synced 2025-02-17 14:08:12 +00:00

259 Commits

Author SHA1 Message Date
Lasse Collin
15358be94a Add SPDX license identifiers to files under tests/ossfuzz
(cherry picked from commit 9ae2ebc1e504a1814b0788de95fb5c58c0328dde)
2024-05-23 11:37:06 +03:00
Lasse Collin
8a99272d4a CMake: Add comments
(cherry picked from commit 9d997d6f9d4f042412e45c7b7a23a14ad2e4f9aa)
2024-05-23 11:36:05 +03:00
Lasse Collin
30982a2153 CMake: Add support for test_files.sh
(cherry picked from commit dc232d584619b2819a9c52d6ad5d8b5d56b392ba)
2024-05-23 11:36:05 +03:00
Lasse Collin
3a8f81e0ad Tests: Make test_files.sh more flexible
Add a new optional argument to specify the directory of the xz and
xzdec executables.

If ../config.h doesn't exist, assume that all encoders and decoders
are available.

(cherry picked from commit a7e9230af9d1f87f474fe38886eb977d4149dc9b)
2024-05-23 11:36:05 +03:00
Lasse Collin
0644675c82 CMake: Add support for test_compress.sh tests
(cherry picked from commit b40e6efbb48d740b9b5b303e59e344801cbb5bd8)
2024-05-23 11:36:05 +03:00
Lasse Collin
dcc02a6ca0 Tests: Make test_compress.sh more flexible
Add a new optional second argument: directory of the xz and xzdec
executables. This is need with the CMake build where the binaries
end up in the top-level build directory.

If ../config.h doesn't exist, assume that all encoders and decoders
are available. This will make this script usable from CMake in the
most common build configuration.

NOTE: Since the existence of ../config.h is checked, the working
directory of the test script must be a subdir in the build tree!
Otherwise ../config.h would look outside the build tree.

Use the default check type instead of forcing CRC32 or CRC64.
Now the script doesn't need to check if CRC64 is available.

(cherry picked from commit ac3222d2cb1ff3a15eb6d58f9ea9bc78e8bc3bb2)
2024-05-23 11:36:05 +03:00
Lasse Collin
c761b7051f CMake: Prepare to support the test_*.sh tests
This is a bit hacky since the scripts grep config.h to know which
features were built but the CMake build doesn't create config.h.
So instead those test scripts will be run only when all relevant
features have been enabled.

(cherry picked from commit 006040b29c83104403621e950ada0c8956c56b3d)
2024-05-23 11:36:05 +03:00
Lasse Collin
a71bc2d75b Tests: test_suffix.sh: Add a comment
(cherry picked from commit 6167607a6ea72fb74eefb943c4566e3cab528cd2)
2024-05-23 11:36:05 +03:00
Lasse Collin
79e329b771 CMake: Add test_suffix.sh to the tests
(cherry picked from commit 7da488cb933fdf51cfc14cb5810beb0766224380)
2024-05-23 11:28:20 +03:00
Lasse Collin
86f33bb90c Test: Add CMake support to test_suffix.sh
It needs to find the xz executable from a different directory
and work without config.h.

(cherry picked from commit a805594ed0b4cbf7b81aa28ff46a8ab3c83c6876)
2024-05-23 11:28:20 +03:00
Lasse Collin
00e774819c Tests: test_index: Fix failures when features are disabled
Fixes: cd88423e76d54eb72aea037364f3ebb21f122503
(cherry picked from commit 710a4573ef2cbd19c66318c3b2d1388e418e26c7)
2024-05-22 23:34:42 +03:00
Lasse Collin
51133ad71e CMake: Keep the build working if the "tests" directory is missing
This moves the tests section as is from CMakeLists.txt into
tests/tests.cmake. CMakeLists.txt now includes tests/tests.cmake
if the latter file exists.

Now it's possible to delete the whole "tests" directory and
building with CMake will still work normally, just without
the tests. This way the tests are readily available for those
who want them, and those who won't run the tests anyway have
a straightforward way to ensure that nothing from the "tests"
directory can affect the build process.

(cherry picked from commit aaff75c3486c4489ce88b0efb36b41cf138af7c3)
2024-05-22 23:34:42 +03:00
Lasse Collin
85b5595b67 Tests: Remove x86 and SPARC BCJ tests
These are very old but the exact test file isn't easy to reproduce
as it was compiled from a short C program (bcj_test.c) long ago.
These tests weren't very good anyway, just a little better than nothing.

(cherry picked from commit a5f2aa5618fe9183706c9c514c3067985f6c338b)
2024-05-22 23:34:42 +03:00
Lasse Collin
d8228d1ea0 Tests: test_index: Edit a misleading test
(cherry picked from commit d879686469c9c4bf2a7c0bb6420ebe4530fc8f07)
2024-05-22 14:32:36 +03:00
Lasse Collin
2358ef8238 Tests: test_index: Use minimal values to test integer overflow
(cherry picked from commit 612005bbdb0dea9dc09e9e2e9cc16a15c1480acd)
2024-05-22 14:32:36 +03:00
Lasse Collin
54f4a4162a Tests: test_index: Test lzma_index_buffer_decode() more
(cherry picked from commit 4ad88b2544c2aaf8de8f38af54587098cbe66c1d)
2024-05-22 14:32:36 +03:00
Lasse Collin
85ab59a6b7 Tests: test_index: Test that *i = NULL is done on LZMA_PROG_ERROR
On LZMA_DATA_ERROR from lzma_index_buffer_decode(), *i = NULL was
already done but this adds a test for that case too.

(cherry picked from commit 575b11b0d291e66c5fce31ce7a72f11436d57c83)
2024-05-22 14:32:36 +03:00
Lasse Collin
fb42599e44 Tests: test_index: Test lzma_index_buffer_encode() with empty output buf
(cherry picked from commit 2c970debdb285823f01f75e875561d893345ac2b)
2024-05-22 14:32:36 +03:00
Lasse Collin
20cac20f63 Tests: test_index: Replace if-statements with tuktest assertions
(cherry picked from commit cd88423e76d54eb72aea037364f3ebb21f122503)
2024-05-22 14:32:36 +03:00
Lasse Collin
91e3ea8735 Tests: test_index: Make it clear that my_alloc() has no integer overflows
liblzma guarantees that the product of the allocation size arguments
will fit in size_t.

Putting the pre-increment in the if-statement was clearly wrong
although in practice it didn't matter here as the function is
called only a couple of times.

(cherry picked from commit 7f865577a6224fbbb5f5ca52574b62ea8ac9bf51)
2024-05-22 14:32:36 +03:00
Lasse Collin
df1659a6c8 Tests: test_index: Verify also iter.block.number_in_stream
(cherry picked from commit 12313a3b6596cdcf012e180597f84d231f8730d3)
2024-05-22 14:32:36 +03:00
Lasse Collin
e083e95dbf Tests: test_index: Check cases that aren't a multiple of 4 bytes
(cherry picked from commit ad2654010d9d641ce1601beeff00630027e6bcd4)
2024-05-22 14:32:36 +03:00
Lasse Collin
b0d3b86ecf Tests: test_index: Edit comments and white space
(cherry picked from commit 2524fcf2b68b662035437cee8edbe80067c0c240)
2024-05-22 14:32:36 +03:00
Lasse Collin
94a462850b Tests: test_filter_str: Add a few assertions
(cherry picked from commit 3ac8a9bb4cccbee88350696dc9c645c48d77c989)
2024-05-22 14:32:36 +03:00
Lasse Collin
72058ca22a Tests: test_filter_str: Move one assertion and add a comment
(cherry picked from commit 26c69be80523b05c84dea86c47c4ddd9a10945d7)
2024-05-22 14:32:36 +03:00
Lasse Collin
c59ebbe1c6 Tests: test_filter_str: Tweak comments and white space
(cherry picked from commit 4f6af853bc99904efb8b6c28a0af7b81a8476c1b)
2024-05-22 14:32:36 +03:00
Lasse Collin
ceda860934 Tests: test_filter_str: Add missing RISC-V case
Fixes: 89ea1a22f4ed3685b053b7260bc5acf6c75d1664
(cherry picked from commit c92663aa1bd576e0615498a4189acf0df12e84b9)
2024-05-22 14:32:36 +03:00
Lasse Collin
2234b7cc47 Tests: test_filter_str: Test *error_pos more thoroughly
(cherry picked from commit b0366df1d7ed26268101f9303a001c91c0806dfc)
2024-05-22 14:32:36 +03:00
Lasse Collin
ba0b5bfe7c Tests: test_filter_flags: Edit comments and style
(cherry picked from commit 2f06920f20b1ad63b7953dc09569e1d424998849)
2024-05-22 14:32:36 +03:00
Lasse Collin
d2ed675959 Tests: Fix C99/C11 compatibility when features are disabled
The array could become empty and then the initializer would be
simply {} which is allowed only in GNU-C and C23.

(cherry picked from commit b101e1d1dbc81577c0c9aa0cb89cf2e46a15eb82)
2024-05-22 14:32:36 +03:00
Lasse Collin
09a0311a1e Tests: test_lzip_decoder: Tweak coding style and comments
(cherry picked from commit 86fc4ee859709da0ff9617a1490f13ddac0a109b)
2024-05-22 14:32:36 +03:00
Lasse Collin
3117336a02 Tests: test_lzip_decoder: Remove redundant initializations
(cherry picked from commit 38be573a279bd7b608ee7d8509ec10884e6fb0d5)
2024-05-22 14:32:36 +03:00
Lasse Collin
f78081eb12 Tests: test_lzip_decoder: Remove unneeded tuktest_malloc() calls
(cherry picked from commit d7e4bc53eacfab9f3de95d8252bdfdc9419079c9)
2024-05-22 14:32:36 +03:00
Lasse Collin
50fb269c7a Tests: test_microlzma: Add a "FIXME?" about LZMA_FINISH handling
(cherry picked from commit fcbd0d199933a69713cb293cbd7409a757d854cd)
2024-05-22 14:32:36 +03:00
Lasse Collin
3e2ff2d38c Tests: test_microlzma: Tweak comments, coding style, and minor details
A few lines were reordered, a few ARRAY_SIZE were changed to sizeof,
and a few uint32_t were changed to size_t. No real functional changes
were intended.

(cherry picked from commit 0fe2dfa68355d2b165544b2bc8babf77dcc2039e)
2024-05-22 14:32:36 +03:00
Lasse Collin
a594b39685 tests/files/README: Update the main heading.
(cherry picked from commit 6b4c859059a7eb9b0547590c081668e14ecf8af6)
2024-05-22 14:12:43 +03:00
Lasse Collin
fa76e3ef59 tests/files/README: Explain how to recreate the ARM64 test files.
(cherry picked from commit 2a851e06b891ce894f918faff32a6cca6fdecee6)
2024-05-22 14:12:43 +03:00
Lasse Collin
ebe9d6d8cb tests/ossfuzz: Tiny fix to a comment.
(cherry picked from commit 408b6adb2a07d07c6535f859571cca38837caaf3)
2024-05-22 14:12:13 +03:00
Lasse Collin
1107712e37 Remove the backdoor found in 5.6.0 and 5.6.1 (CVE-2024-3094).
While the backdoor was inactive (and thus harmless) without inserting
a small trigger code into the build system when the source package was
created, it's good to remove this anyway:

  - The executable payloads were embedded as binary blobs in
    the test files. This was a blatant violation of the
    Debian Free Software Guidelines.

  - On machines that see lots bots poking at the SSH port, the backdoor
    noticeably increased CPU load, resulting in degraded user experience
    and thus overwhelmingly negative user feedback.

  - The maintainer who added the backdoor has disappeared.

  - Backdoors are bad for security.

This reverts the following without making any other changes:

6e636819 Tests: Update two test files.
a3a29bbd Tests: Test --single-stream can decompress bad-3-corrupt_lzma2.xz.
0b4ccc91 Tests: Update RISC-V test files.
8c9b8b20 liblzma: Fix typos in crc32_fast.c and crc64_fast.c.
82ecc538 liblzma: Fix false Valgrind error report with GCC.
cf44e4b7 Tests: Add a few test files.
3060e107 Tests: Use smaller dictionary size in RISC-V test files.
e2870db5 Tests: Add two RISC-V Filter test files.

The RISC-V test files also have real content that tests the filter
but the real content would fit into much smaller files. A generator
program would need to be available as well.

Thanks to Andres Freund for finding and reporting it and making
it public quickly so others could act without a delay.
See: https://www.openwall.com/lists/oss-security/2024/03/29/4
2024-04-09 18:38:37 +03:00
Jia Tan
74b138d2a6 Tests: Update two test files.
The original files were generated with random local to my machine.
To better reproduce these files in the future, a constant seed was used
to recreate these files.
2024-03-09 10:18:29 +08:00
Jia Tan
3ec6dfd656 Tests: Test --single-stream can decompress bad-3-corrupt_lzma2.xz.
The first stream in this file is valid, so this tests that xz properly
stops after decompressing it.
2024-03-09 10:08:32 +08:00
Jia Tan
a67dcce610 Tests: Update RISC-V test files.
This increases code coverage and tests for possible shifting bugs.
2024-03-09 10:05:32 +08:00
Jia Tan
cd5de9c1bb Tests: Replace HAVE_MICROLZMA usage in CMake and Autotools builds.
This reverts commit adaacafde6661496ca2814b1e94a3ba5186428cb.
2024-03-09 09:49:55 +08:00
Jia Tan
42ee425673 Tests: Correct license header in test_microlzma.c. 2024-02-28 18:31:04 +02:00
Jia Tan
cf44e4b7f5 Tests: Add a few test files. 2024-02-23 23:09:59 +08:00
Jia Tan
39f4a1a86a Tests: Add MicroLZMA test. 2024-02-23 20:58:36 +08:00
Lasse Collin
74e8bc7417 CMake: Add test_scripts.sh to the tests.
In contrast to Automake, skipping of this test when decoders
are disabled is handled at CMake side instead of test_scripts.sh
because CMake-build doesn't create config.h.
2024-02-19 12:21:37 +02:00
Lasse Collin
5394a1665b Tests: tuktest.h: Treat Clang separately from GCC.
Don't assume that Clang defines __GNUC__ as the extensions
are available in clang-cl as well (and possibly in some other
Clang variants?).
2024-02-14 21:12:58 +02:00
Lasse Collin
cce7330b9f Tests: tuktest.h: Add a missing word to a comment. 2024-02-14 21:11:03 +02:00
Lasse Collin
5dd8fc9452 Tests: tuktest.h: Fix the comment about STest. 2024-02-14 21:10:10 +02:00