1
0
mirror of https://git.tukaani.org/xz.git synced 2025-04-23 08:00:54 +00:00

2904 Commits

Author SHA1 Message Date
Lasse Collin
56aa9a0796
CI: Valgrind: Improve the skipping of traced child processes
Use --trace-children-skip instead of --trace-children-skip-by-arg
so that the skipping is only done based on the executable names.
(--trace-children-skip-by-arg can match other args than argv[0].)

Update the list of executables to skip to match what the scripts run.

Do not skip bash or sh. If Valgrind didn't trace the shell, then the
xz and xzdec programs run by the shell wouldn't be analyzed either.

Fixes: 7e99856f66c0 ("CI: Speed up Valgrind job by using --trace-children-skip-by-arg=...")
2025-04-22 21:26:21 +03:00
Lasse Collin
f33da20b75
CI: Valgrind: Test with static liblzma
If shared liblzma is built, tests/test_* and src/xz/xz are wrapper
scripts created by Libtool. The wrappers set library search path
so that the freshly-built shared library is found.

With a static liblzma, no wrapper scripts are needed, and Libtool
places the real executables to the aforementioned locations. This
speeds up the tests under Valgrind dramatically.

Fixes: 6c095a98fbec ("ci: test Valgrind")
2025-04-22 21:26:21 +03:00
Lasse Collin
5606fa89f9
CI: Add Ubuntu on ARM64 2025-04-22 21:26:15 +03:00
Lasse Collin
ec047a65a0
Doxygen: Update the comment about tested versions 2025-04-22 19:00:20 +03:00
Lasse Collin
4f86e77bef
Doxygen: Set HAVE_DOT = NO
Debian and Ubuntu have a patch that changes the upstream default to
HAVE_DOT = YES. Undo it to have more consistent results across distros.

This was noticed in Ubuntu CI runner where "doxygen" tried to run "dot"
but that failed due to "dot" not being installed. "doxygen" still
finished with exit status 0 until the commit that turned warnings to
errors with WARN_AS_ERROR = FAIL_ON_WARNINGS.
2025-04-22 19:00:20 +03:00
Lasse Collin
ff96542d1c
Doxygen: Treat warnings as errors
Also set WARN_IF_UNDOCUMENTED = NO because even the API headers have
a few things that won't have their own docs.
2025-04-22 19:00:20 +03:00
Lasse Collin
a6711d1c4a
Doxygen: Fix errors and some warnings in internal docs 2025-04-22 19:00:19 +03:00
Lasse Collin
8efd80adfc
CI: Use --disable-sandbox instead of --enable-sandbox=no
It's the same thing, just a style difference.
2025-04-22 19:00:19 +03:00
Lasse Collin
a2e47c7a59
CI: Support Doxygen in ci_build.bash 2025-04-22 19:00:19 +03:00
Lasse Collin
9048e72494
CI: Add Doxygen dependency to CMake builds on Ubuntu and macOS 2025-04-22 19:00:19 +03:00
Lasse Collin
d8e9dc63a6
CI: Support XZ_NLS=OFF with CMake 2025-04-22 19:00:19 +03:00
Lasse Collin
ffa9fadecc
CI: Revise MSYS2
Re-enable CLANG64 environment. Add CLANGARM64. Don't add MINGW64
to slightly reduce the number of runner VMs needed.

Install the required packages using the setup-msys2 action instead
of running the commands separately.

Test Autotools and CMake in the same job to reduce the number of VMs.
This doesn't slow it down too much because the msys2-setup step is
needed by both. However, do only the full builds on ARM64 because
those runners seem to be slower.

Test fewer build configurations. The point of testing on MSYS2 is to
catch Windows-related issues. It should be enough that the more unusual
build configurations are tested in ci.yml.

Run the build commands directly instead of using ci_build.bash. This
makes it easier to see what commands are run even if it is a little
more verbose now.

Run the workflow automatically when commit are pushed to master.
With the fewer build variants it's not too slow.
2025-04-22 19:00:19 +03:00
Lasse Collin
6f2aaa77da
CI: Rename the MSYS2 workflow file 2025-04-22 19:00:19 +03:00
Lasse Collin
09110ad4c7
CI: Enable assertions on NetBSD + CMake 2025-04-22 19:00:10 +03:00
Lasse Collin
516b90f6e1
liblzma: Update lzma_lzip_decoder() docs about trailing data
Don't say that the .lz format allows trailing data. According to the
lzip 1.25 manual, trailing data isn't part of the file format at all.
However, tools are still expected to behave as usefully as possible
when there is trailing data.

Fix the description of lzip >= 1.20 behavior when some of the first
bytes of trailing data match the magic bytes. While the lzip 1.25 manual
recommends that none of the first four bytes in trailing data should
match the magic bytes, the default behavior of lzip 1.25 treats
trailing data as a corrupt member header only if two or three bytes
match the magic bytes; one matching byte isn't enough.

Reported-by: Antonio Diaz Diaz
Link: https://www.mail-archive.com/xz-devel@tukaani.org/msg00702.html
2025-04-21 12:23:37 +03:00
Lasse Collin
c330220d47
Update THANKS 2025-04-21 11:21:08 +03:00
Lasse Collin
6cc7672c22
CI: Add DragonflyBSD 2025-04-17 20:38:20 +03:00
Lasse Collin
07dc509137
CI: Update Solaris 2025-04-17 20:38:20 +03:00
Lasse Collin
cfcaae1945
CI: Update OpenBSD
Use --disable-nls --enable-external-sha256 because those are used
in the xz Makefile in the OpenBSD ports tree.
2025-04-17 20:38:20 +03:00
Lasse Collin
5240fcfee3
CI: Update NetBSD
For variety, use CMake and Ninja.
2025-04-17 20:38:20 +03:00
Lasse Collin
85ff0cf0ce
CI: Update FreeBSD
ARM64 was left commented out because it's slow under both
ubuntu-latest (x86-64) and ubuntu-24.04-arm (aarch64) hosts.
2025-04-17 20:38:06 +03:00
Lasse Collin
907ac2215d
CI: Specify only the main version of the standard GH actions 2025-04-17 18:43:16 +03:00
Lasse Collin
b0d0e62474
CI: Add 'permissions' to ci.yml and msvc.yml 2025-04-17 18:43:03 +03:00
Sam James
1edc14e8ca
CI: Add CIFuzz
xz is already part of OSS-Fuzz, but OSS-Fuzz provides & encourages [0]
its 'CIFuzz' service to test individual commits.

[0] https://google.github.io/oss-fuzz/getting-started/continuous-integration/

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
2025-04-17 18:38:52 +03:00
Lasse Collin
35e06c4c42
CMake: Don't check for optreset if using replacement getopt_long
If <getopt.h> had optreset but not getopt_long, xz used optreset while
the replacement getopt_long doesn't support optreset. I'm not aware of
any relevant system where bug is possible. Autotools build didn't have
this bug.

Fixes: af66cd585902 ("CMake: Add support for replacement getopt_long (lib/getopt*).")
2025-04-17 18:36:54 +03:00
Lasse Collin
99f4b9db9d
Update THANKS 2025-04-17 18:33:10 +03:00
Lasse Collin
dd006a67e5
liblzma: Update the lzma_lzip_decoder() docs about sync flush marker 2025-04-17 18:30:26 +03:00
Lasse Collin
f59c585960
xz: Don't mention lzip's sync flush marker on the man page
The sync flush marker isn't valid in .lz files. The sync flush marker
may be used by lzlib, but the resulting streams are only meant to be
decoded by lzlib itself. lzlib's docs make this clear.

Reported-by: Antonio Diaz Diaz
Link: https://www.mail-archive.com/xz-devel@tukaani.org/msg00700.html
Link: https://www.mail-archive.com/xz-devel@tukaani.org/msg00701.html
2025-04-17 18:16:40 +03:00
Lasse Collin
49258439b4
Update THANKS 2025-04-17 18:15:48 +03:00
Lasse Collin
a69fbd3aae
CI: MSVC: Use fewer runners for the same number of tests
Using eight runners seems wasteful. Using only two runners isn't
much slower due to the runner startup overhead.

Also add a comment about the test that fails without b5a5d9e3f702.
2025-04-10 20:13:07 +03:00
Lasse Collin
8a300d1c4f
Update THANKS 2025-04-10 20:10:31 +03:00
Lasse Collin
b5a5d9e3f7
liblzma: Disable CLMUL CRC on old MSVC targeting 32-bit x86
On GitHub runners, VS 2019 16.11 (MSVC 19.29.30158) results in
test failures. VS 2022 17.13 (MSVC 19.43.34808) works.

In xz 5.6.x there was a #pragma-based workaround for MSVC builds for
32-bit x86. Another method was thought to work with the new rewritten
CLMUL CRC. Apparently it doesn't. Keep it simple and disable CLMUL CRC
with any non-recent MSVC when building for 32-bit x86.

Fixes: 54eaea5ea49b ("liblzma: x86 CLMUL CRC: Rewrite")
Fixes: https://github.com/tukaani-project/xz/issues/171
Reported-by: Andrew Murray
2025-04-07 22:36:58 +03:00
Lasse Collin
c5fd88dfc3
liblzma: Remove MSVC hack from CLMUL CRC
It's not enough with MSVC 19.29 (VS 2019) even if the hack was also
applied to the CRC32 code. The tests crash when built for 32-bit x86.
2025-04-07 22:36:58 +03:00
Lasse Collin
49ba8c69ea
CI: Test 32/64-bit x86 builds with Visual Studio 2019 and 2022 2025-04-07 22:36:52 +03:00
Lasse Collin
1176a19df6
Tests: Add fuzz_decode_stream_mt.options 2025-04-04 20:08:37 +03:00
Lasse Collin
c3cb1e53a1
doc/SHA256SUMS: Add 5.8.1 2025-04-03 15:06:07 +03:00
Lasse Collin
a522a22654
Bump version and soname for 5.8.1 v5.8.1 2025-04-03 14:34:43 +03:00
Lasse Collin
1c462c2ad8
Add NEWS for 5.8.1 2025-04-03 14:34:43 +03:00
Lasse Collin
513cabcf7f
Tests: Call lzma_code() in smaller chunks in fuzz_common.h
This makes it easy to crash fuzz_decode_stream_mt when tested
against the code from 5.8.0.

Obviously this might make it harder to reach some other code path now.
The previous code has been in use since 2018 when fuzzing was added
in 106d1a663d4b ("Tests: Add a fuzz test program and a config file
for OSS-Fuzz.").
2025-04-03 14:34:43 +03:00
Lasse Collin
48440e24a2
Tests: Add a fuzzing target for the multithreaded .xz decoder
It doesn't seem possible to trigger the CVE-2025-31115 bug with this
fuzzing target at the moment. It's because the code in fuzz_common.h
passes the whole input buffer to lzma_code() at once.
2025-04-03 14:34:43 +03:00
Lasse Collin
0c80045ab8
liblzma: mt dec: Fix lack of parallelization in single-shot decoding
Single-shot decoding means calling lzma_code() by giving it the whole
input at once and enough output buffer space to store the uncompressed
data, and combining this with LZMA_FINISH and no timeout
(lzma_mt.timeout = 0). This way the file is decoded with a single
lzma_code() call if possible.

The bug prevented the decoder from starting more than one worker thread
in single-shot mode. The issue was noticed when reviewing the code;
there are no bug reports. Thus maybe few have tried this mode.

Fixes: 64b6d496dc81 ("liblzma: Threaded decoder: Always wait for output if LZMA_FINISH is used.")
2025-04-03 14:34:42 +03:00
Lasse Collin
8188048854
liblzma: mt dec: Don't modify thr->in_size in the worker thread
Don't set thr->in_size = 0 when returning the thread to the stack of
available threads. Not only is it useless, but the main thread may
read the value in SEQ_BLOCK_THR_RUN. With valid inputs, it made
no difference if the main thread saw the original value or 0. With
invalid inputs (when worker thread stops early), thr->in_size was
no longer modified after the previous commit with the security fix
("Don't free the input buffer too early").

So while the bug appears harmless now, it's important to fix it because
the variable was being modified without proper locking. It's trivial
to fix because there is no need to change the value. Only main thread
needs to set the value in (in SEQ_BLOCK_THR_INIT) when starting a new
Block before the worker thread is activated.

Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Thanks-to: Sam James <sam@gentoo.org>
2025-04-03 14:34:42 +03:00
Lasse Collin
d5a2ffe41b
liblzma: mt dec: Don't free the input buffer too early (CVE-2025-31115)
The input buffer must be valid as long as the main thread is writing
to the worker-specific input buffer. Fix it by making the worker
thread not free the buffer on errors and not return the worker thread to
the pool. The input buffer will be freed when threads_end() is called.

With invalid input, the bug could at least result in a crash. The
effects include heap use after free and writing to an address based
on the null pointer plus an offset.

The bug has been there since the first committed version of the threaded
decoder and thus affects versions from 5.3.3alpha to 5.8.0.

As the commit message in 4cce3e27f529 says, I had made significant
changes on top of Sebastian's patch. This bug was indeed introduced
by my changes; it wasn't in Sebastian's version.

Thanks to Harri K. Koskinen for discovering and reporting this issue.

Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
Reported-by: Harri K. Koskinen <x64nop@nannu.org>
Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Thanks-to: Sam James <sam@gentoo.org>
2025-04-03 14:34:42 +03:00
Lasse Collin
c0c835964d
liblzma: mt dec: Simplify by removing the THR_STOP state
The main thread can directly set THR_IDLE in threads_stop() which is
called when errors are detected. threads_stop() won't return the stopped
threads to the pool or free the memory pointed by thr->in anymore, but
it doesn't matter because the existing workers won't be reused after
an error. The resources will be cleaned up when threads_end() is
called (reinitializing the decoder always calls threads_end()).

Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Thanks-to: Sam James <sam@gentoo.org>
2025-04-03 14:34:42 +03:00
Lasse Collin
831b55b971
liblzma: mt dec: Fix a comment
Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Thanks-to: Sam James <sam@gentoo.org>
2025-04-03 14:34:42 +03:00
Lasse Collin
b9d168eee4
liblzma: Add assertions to lzma_bufcpy() 2025-04-03 14:34:30 +03:00
Lasse Collin
c8e0a4897b
DOS: Update Makefile to fix the build 2025-04-02 16:54:40 +03:00
Lasse Collin
307c02ed69
sysdefs.h: Avoid <stdalign.h> even with C11 compilers
Oracle Developer Studio 12.6 on Solaris 10 claims C11 support in
__STDC_VERSION__ and supports _Alignas. However, <stdalign.h> is missing.
We only need alignas, so define it to _Alignas with C11/C17 compilers.
If something included <stdalign.h> later, it shouldn't cause problems.

Thanks to Ihsan Dogan for reporting the issue and testing the fix.

Fixes: c0e7eaae8d6eef1e313c9d0da20ccf126ec61f38
2025-03-29 12:41:32 +02:00
Lasse Collin
7ce38b3183
Update THANKS 2025-03-29 12:32:05 +02:00
Lasse Collin
688e51bde4
Translations: Update the Croatian translation 2025-03-29 12:21:51 +02:00