]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
2 years agoTranslations: Update the Croatian translation.
Lasse Collin [Fri, 11 Nov 2022 15:58:18 +0000 (17:58 +0200)] 
Translations: Update the Croatian translation.

2 years agoTranslations: Update the Polish translation.
Lasse Collin [Fri, 11 Nov 2022 15:57:18 +0000 (17:57 +0200)] 
Translations: Update the Polish translation.

2 years agoTranslations: Update the Spanish translation.
Lasse Collin [Fri, 11 Nov 2022 15:56:44 +0000 (17:56 +0200)] 
Translations: Update the Spanish translation.

2 years agoUpdate THANKS.
Lasse Collin [Fri, 11 Nov 2022 15:16:03 +0000 (17:16 +0200)] 
Update THANKS.

2 years agoliblzma: Fix building with Intel ICC (the classic compiler).
Lasse Collin [Fri, 11 Nov 2022 15:15:25 +0000 (17:15 +0200)] 
liblzma: Fix building with Intel ICC (the classic compiler).

It claims __GNUC__ >= 10 but doesn't support __symver__ attribute.

Thanks to Stephen Sachs.

2 years agoliblzma: Fix incorrect #ifdef for x86 SSE2 support.
Lasse Collin [Fri, 11 Nov 2022 12:35:58 +0000 (14:35 +0200)] 
liblzma: Fix incorrect #ifdef for x86 SSE2 support.

__SSE2__ is the correct macro for SSE2 support with GCC, Clang,
and ICC. __SSE2_MATH__ means doing floating point math with SSE2
instead of 387. Often the latter macro is defined if the first
one is but it was still a bug.

2 years agoAdd NEWS for 5.2.7 (forgotten cherry-pick from v5.2).
Lasse Collin [Fri, 11 Nov 2022 11:27:06 +0000 (13:27 +0200)] 
Add NEWS for 5.2.7 (forgotten cherry-pick from v5.2).

2 years agoxzdiff: Add support for .lz files.
Lasse Collin [Fri, 11 Nov 2022 11:16:21 +0000 (13:16 +0200)] 
xzdiff: Add support for .lz files.

The other scripts don't need changes for .lz support because
in those scripts it is enough that xz supports .lz.

2 years agoScripts: Ignore warnings from xz.
Lasse Collin [Fri, 11 Nov 2022 10:23:58 +0000 (12:23 +0200)] 
Scripts: Ignore warnings from xz.

In practice this means making the scripts work when
the input files have an unsupported check type which
isn't a problem in practice unless support for
some check types has been disabled at build time.

2 years agoTranslations: Rename poa4/fr_FR.po to po4a/fr.po.
Lasse Collin [Thu, 10 Nov 2022 10:34:43 +0000 (12:34 +0200)] 
Translations: Rename poa4/fr_FR.po to po4a/fr.po.

That's how it is preferred at the Translation Project.
On my system /usr/share/man/fr_FR doesn't contain any
other man pages than XZ Utils while /usr/share/man/fr
has quite a few, so this will fix that too.

Thanks to Benno Schulenberg from the Translation Project.

2 years agoxz: Update the man page about BCJ filters, including upcoming --arm64.
Lasse Collin [Wed, 9 Nov 2022 16:48:50 +0000 (18:48 +0200)] 
xz: Update the man page about BCJ filters, including upcoming --arm64.

The --arm64 isn't actually implemented yet in the form
described in this commit.

Thanks to Jia Tan.

2 years agoxz: Add --arm64 to --long-help and omit endianness from ARM(-Thumb).
Lasse Collin [Wed, 9 Nov 2022 16:14:14 +0000 (18:14 +0200)] 
xz: Add --arm64 to --long-help and omit endianness from ARM(-Thumb).

Modern 32-bit ARM in big endian mode use little endian for
instruction encoding still, so the filters work on such
executables too. It's likely less confusing for users this way.

The --arm64 option hasn't been implemented yet (there is
--experimental-arm64 but it's different). The --arm64 option
is added now anyway because this is the likely result and the
strings need to be ready for translators.

Thanks to Jia Tan.

2 years agoWindows: Update the VS project files for ARM64 and .lz support.
Lasse Collin [Wed, 9 Nov 2022 13:12:13 +0000 (15:12 +0200)] 
Windows: Update the VS project files for ARM64 and .lz support.

2 years agoDOS: Update Makefile and config.h to include ARM64 and .lz support.
Lasse Collin [Wed, 9 Nov 2022 12:57:48 +0000 (14:57 +0200)] 
DOS: Update Makefile and config.h to include ARM64 and .lz support.

2 years agoCMake: Add lzip decoder files and #define to the build.
Lasse Collin [Wed, 9 Nov 2022 12:45:05 +0000 (14:45 +0200)] 
CMake: Add lzip decoder files and #define to the build.

2 years agoDocs: Update INSTALL and also add new prohibited options to PACKAGERS.
Lasse Collin [Wed, 9 Nov 2022 12:41:56 +0000 (14:41 +0200)] 
Docs: Update INSTALL and also add new prohibited options to PACKAGERS.

2 years agoTests: Test the .lz files in test_files.sh.
Lasse Collin [Thu, 20 Oct 2022 14:39:06 +0000 (17:39 +0300)] 
Tests: Test the .lz files in test_files.sh.

2 years agoTests: Add .lz (lzip) test files.
Lasse Collin [Thu, 20 Oct 2022 12:35:59 +0000 (15:35 +0300)] 
Tests: Add .lz (lzip) test files.

2 years agoxz: Remove the commented-out FORMAT_GZIP, gzip, .gz, and .tgz.
Lasse Collin [Wed, 19 Oct 2022 19:32:51 +0000 (22:32 +0300)] 
xz: Remove the commented-out FORMAT_GZIP, gzip, .gz, and .tgz.

2 years agoxz: Add .lz (lzip) decompression support.
Lasse Collin [Sat, 8 Oct 2022 18:28:15 +0000 (21:28 +0300)] 
xz: Add .lz (lzip) decompression support.

If configured with --disable-lzip-decoder then --long-help will
still list `lzip' in --format but I left it like that since
due to translations it would be messy to have two help strings.
Features are disabled only in special situations so wrong help
in such a situation shouldn't matter much.

Thanks to Michał Górny for the original patch.

2 years agoliblzma: Add .lz support to lzma_auto_decoder().
Lasse Collin [Fri, 7 Oct 2022 21:29:20 +0000 (00:29 +0300)] 
liblzma: Add .lz support to lzma_auto_decoder().

Thanks to Michał Górny for the original patch.

2 years agoliblzma: Add .lz (lzip) decompression support (format versions 0 and 1).
Lasse Collin [Thu, 6 Oct 2022 12:50:20 +0000 (15:50 +0300)] 
liblzma: Add .lz (lzip) decompression support (format versions 0 and 1).

Support for format version 0 was removed from lzip 1.18 for some
reason. .lz format version 0 files are rare (and old) but some
source packages were released in this format, and some people might
have personal files in this format too. It's very little extra code
to support it along side format version 1 so this commits adds
support for both.

The Sync Flush marker extentension to the original .lz format
version 1 isn't supported. It would require changes to the
LZMA decoder itself. Such files are very rare anyway.

See the API doc for lzma_lzip_decoder() for more details about
the .lz format support.

Thanks to Michał Górny for the original patch.

2 years agoliblzma: Add the missing Makefile.inc change for --disable-microlzma.
Lasse Collin [Wed, 9 Nov 2022 12:17:23 +0000 (14:17 +0200)] 
liblzma: Add the missing Makefile.inc change for --disable-microlzma.

This was forgotten from commit 59c4d6e1390f6f4176f43ac1dad1f7ac03c449b8.

2 years agoxz: Add comments about stdin and src_st.st_size.
Lasse Collin [Wed, 9 Nov 2022 12:10:52 +0000 (14:10 +0200)] 
xz: Add comments about stdin and src_st.st_size.

"xz -v < regular_file > out.xz" doesn't display the percentage
and estimated remaining time because it doesn't even try to
check the input file size when input is read from stdin.
This could be improved but for now there's just a comment
to remind about it.

2 years agoxz: Fix displaying of file sizes in progress indicator in passthru mode.
Lasse Collin [Wed, 9 Nov 2022 10:48:22 +0000 (12:48 +0200)] 
xz: Fix displaying of file sizes in progress indicator in passthru mode.

It worked for one input file since the counters are zero when
xz starts but they weren't reset when starting a new file in
passthru mode. For example, if files A, B, and C are one byte each,
then "xz -dcvf A B C" would show file sizes as 1, 2, and 3 bytes
instead of 1, 1, and 1 byte.

2 years agoxz: Add a comment why --to-stdout is not in --help.
Lasse Collin [Wed, 9 Nov 2022 09:27:20 +0000 (11:27 +0200)] 
xz: Add a comment why --to-stdout is not in --help.

It is on the man page still.

2 years agoxz: Make xz -lvv show that the upcoming --arm64 needs 5.4.0 to decompress.
Lasse Collin [Tue, 8 Nov 2022 21:05:37 +0000 (23:05 +0200)] 
xz: Make xz -lvv show that the upcoming --arm64 needs 5.4.0 to decompress.

2 years agoDocs: Update faq.txt a little.
Lasse Collin [Tue, 8 Nov 2022 20:26:54 +0000 (22:26 +0200)] 
Docs: Update faq.txt a little.

2 years agoTranslations: Update Turkish translation.
Lasse Collin [Tue, 8 Nov 2022 14:57:17 +0000 (16:57 +0200)] 
Translations: Update Turkish translation.

2 years agoTranslations: Update Croatian translation.
Lasse Collin [Tue, 8 Nov 2022 12:55:32 +0000 (14:55 +0200)] 
Translations: Update Croatian translation.

2 years agoliblzma: Update API docs about decoder flags.
Lasse Collin [Tue, 8 Nov 2022 12:13:03 +0000 (14:13 +0200)] 
liblzma: Update API docs about decoder flags.

2 years agoliblzma: Use the return_if_error() macro in alone_decoder.c.
Lasse Collin [Tue, 8 Nov 2022 12:01:50 +0000 (14:01 +0200)] 
liblzma: Use the return_if_error() macro in alone_decoder.c.

2 years agoliblzma: Fix a comment in auto_decoder.c.
Lasse Collin [Tue, 8 Nov 2022 12:00:58 +0000 (14:00 +0200)] 
liblzma: Fix a comment in auto_decoder.c.

2 years agoxz: Initialize the pledge(2) sandbox at the very beginning of main().
Lasse Collin [Tue, 8 Nov 2022 11:43:19 +0000 (13:43 +0200)] 
xz: Initialize the pledge(2) sandbox at the very beginning of main().

It feels better that the initializations are sandboxed too.
They don't do anything that the pledge() call wouldn't allow.

2 years agoxz: Extend --robot --info-memory output.
Lasse Collin [Mon, 7 Nov 2022 20:51:16 +0000 (22:51 +0200)] 
xz: Extend --robot --info-memory output.

Now it includes everything that the human-readable --info-memory shows.

2 years agoliblzma: Include cached memory in reported memusage in threaded decoder.
Lasse Collin [Mon, 7 Nov 2022 15:22:04 +0000 (17:22 +0200)] 
liblzma: Include cached memory in reported memusage in threaded decoder.

This affects lzma_memusage() and lzma_memlimit_set() when used
with the threaded decompressor. Now all allocations are reported
by lzma_memusage() (so it's not misleading) and lzma_memlimit_set()
cannot lower the limit below that value.

The alternative would have been to allow lowering the limit if
doing so is possible by freeing the cached memory but since
the primary use case of lzma_memlimit_set() is to increase
memlimit after LZMA_MEMLIMIT_ERROR this simple approach
was selected.

The cached memory was always included when enforcing
the memory usage limit while decoding.

Thanks to Jia Tan.

2 years agoxz: Avoid a compiler warning in progress_speed() in message.c.
Jia Tan [Mon, 7 Nov 2022 14:24:14 +0000 (16:24 +0200)] 
xz: Avoid a compiler warning in progress_speed() in message.c.

This should be smaller too since it avoids the string constants.

2 years agoBuild: Clarify comment in configure.ac about SSE2.
Lasse Collin [Mon, 31 Oct 2022 14:26:05 +0000 (16:26 +0200)] 
Build: Clarify comment in configure.ac about SSE2.

2 years agoBuild: Remove obsolete commented-out lines from configure.ac.
Lasse Collin [Mon, 31 Oct 2022 14:16:37 +0000 (16:16 +0200)] 
Build: Remove obsolete commented-out lines from configure.ac.

2 years agoWindows: Fix mythread_once() macro with Vista threads.
Lasse Collin [Mon, 31 Oct 2022 11:31:58 +0000 (13:31 +0200)] 
Windows: Fix mythread_once() macro with Vista threads.

Don't call InitOnceComplete() if initialization was already done.

So far mythread_once() has been needed only when building
with --enable-small. windows/build.bash does this together
with --disable-threads so the Vista-specific mythread_once()
is never needed by those builds. VS project files or
CMake-builds don't support HAVE_SMALL builds at all.

2 years agoliblzma: Silence -Wconversion warning from crc64_fast.c.
Lasse Collin [Mon, 31 Oct 2022 09:54:44 +0000 (11:54 +0200)] 
liblzma: Silence -Wconversion warning from crc64_fast.c.

2 years agoCMake: Sync tuklib_cpucores.cmake with tuklib_cpucores.m4.
Lasse Collin [Mon, 31 Oct 2022 09:49:47 +0000 (11:49 +0200)] 
CMake: Sync tuklib_cpucores.cmake with tuklib_cpucores.m4.

This was forgotten from commit 2611c4d90535652d3eb7ef4a026a6691276fab43.

2 years agoTests: test_files.sh: Make it not fail if features were disabled at build.
Lasse Collin [Thu, 27 Oct 2022 12:49:18 +0000 (15:49 +0300)] 
Tests: test_files.sh: Make it not fail if features were disabled at build.

It now tries to test as many files as easily possible.
The exit status indicates skipping if any of the files were
skipped. This way it is easy to notice if something is being
skipped when it isn't expected.

2 years agoTests: test_files.sh: Suppress an expected warning from the log.
Lasse Collin [Thu, 27 Oct 2022 12:30:13 +0000 (15:30 +0300)] 
Tests: test_files.sh: Suppress an expected warning from the log.

xz (but not xzdec) will normally warn about unsupported check
but since we are testing specifically such a file, it's better
to silence that warning so that it doesn't look suspicious in
test_files.sh.log.

The use of -q and -Q in xzdec is just for consistency and
doesn't affect the result at least for now.

2 years agoTests: test_files.sh: Print the reason for skipping if xz & xzdec missing.
Lasse Collin [Thu, 27 Oct 2022 12:27:50 +0000 (15:27 +0300)] 
Tests: test_files.sh: Print the reason for skipping if xz & xzdec missing.

2 years agoTests: Keep test_compress_* working when some filters are unavailable.
Lasse Collin [Wed, 26 Oct 2022 22:12:40 +0000 (01:12 +0300)] 
Tests: Keep test_compress_* working when some filters are unavailable.

2 years agoTests: test_bcj_exact_size skips properly now if PowerPC filter disabled.
Jia Tan [Sun, 23 Oct 2022 13:01:08 +0000 (21:01 +0800)] 
Tests: test_bcj_exact_size skips properly now if PowerPC filter disabled.

2 years agoTests: Test also unsupported-*.xz.
Lasse Collin [Tue, 25 Oct 2022 21:05:57 +0000 (00:05 +0300)] 
Tests: Test also unsupported-*.xz.

2 years agoBuild: Use AC_CONFIG_HEADERS instead of the ancient AC_CONFIG_HEADER.
Lasse Collin [Tue, 25 Oct 2022 20:45:03 +0000 (23:45 +0300)] 
Build: Use AC_CONFIG_HEADERS instead of the ancient AC_CONFIG_HEADER.

We require Autoconf >= 2.69 and that has AC_CONFIG_HEADERS.

There is a warning about AC_PROG_CC_C99 being obsolete but
it cannot be removed because it is needed with Autoconf 2.69.

2 years agoBuild: Update m4/ax_pthread.m4 from Autoconf Archive.
Lasse Collin [Tue, 25 Oct 2022 20:31:44 +0000 (23:31 +0300)] 
Build: Update m4/ax_pthread.m4 from Autoconf Archive.

2 years agoBuild: Add configure option --disable-microlzma.
Lasse Collin [Tue, 25 Oct 2022 20:28:34 +0000 (23:28 +0300)] 
Build: Add configure option --disable-microlzma.

MicroLZMA was made for EROFS and used by erofs-utils.
It might be used by something else in the future but
those wanting a smaller build for specific situations
can now disable this rarely-needed feature.

2 years agoxz: Fix --single-stream with an empty .xz Stream.
Lasse Collin [Tue, 25 Oct 2022 20:09:11 +0000 (23:09 +0300)] 
xz: Fix --single-stream with an empty .xz Stream.

Example:

    $ xz -dc --single-stream good-0-empty.xz
    xz: good-0-empty.xz: Internal error (bug)

The code, that is tries to catch some input file issues early,
didn't anticipate LZMA_STREAM_END which is possible in that
code only when --single-stream is used.

2 years agoxz: Add support for OpenBSD's pledge() sandbox.
Lasse Collin [Tue, 25 Oct 2022 18:11:58 +0000 (21:11 +0300)] 
xz: Add support for OpenBSD's pledge() sandbox.

2 years agoxz: Fix decompressor behavior if input uses an unsupported check type.
Lasse Collin [Tue, 25 Oct 2022 16:07:17 +0000 (19:07 +0300)] 
xz: Fix decompressor behavior if input uses an unsupported check type.

Now files with unsupported check will make xz display
a warning, set the exit status to 2 (unless --no-warn is used),
and then decompress the file normally. This is how it was
supposed to work since the beginning but this was broken by
the commit 231c3c7098f1099a56abb8afece76fc9b8699f05, that is,
a little before 5.0.0 was released. The buggy behavior displayed
a message, set exit status 1 (error), and xz didn't attempt to
to decompress the file.

This doesn't matter today except for special builds that disable
CRC64 or SHA-256 at build time (but such builds should be used
in special situations only). The bug matters if new check type
is added in the future and an old xz version is used to decompress
such a file; however, it's likely that such files would use a new
filter too and an old xz wouldn't be able to decompress the file
anyway.

The first hunk in the commit is the actual fix. The second hunk
is a cleanup since LZMA_TELL_ANY_CHECK isn't used in xz.

There is a test file for unsupported check type but it wasn't
used by test_files.sh, perhaps due to different behavior between
xz and the simpler xzdec.

2 years agoxz: Clarify the man page: input file isn't removed if an error occurs.
Lasse Collin [Tue, 25 Oct 2022 15:36:19 +0000 (18:36 +0300)] 
xz: Clarify the man page: input file isn't removed if an error occurs.

2 years agoxz: Refactor to remove is_empty_filename().
Lasse Collin [Tue, 25 Oct 2022 15:30:55 +0000 (18:30 +0300)] 
xz: Refactor to remove is_empty_filename().

Long ago it was used in list.c too but nowadays it's needed
only in io_open_src() so it's nicer to avoid a separate function.

2 years agoxz: If input file cannot be removed, treat it as a warning, not error.
Lasse Collin [Tue, 25 Oct 2022 15:23:54 +0000 (18:23 +0300)] 
xz: If input file cannot be removed, treat it as a warning, not error.

Treating it as a warning (message + exit status 2) matches gzip
and it seems more logical as at that point the output file has
already been successfully closed. When it's a warning it is
possible to suppress it with --no-warn.

2 years agoliblzma: Threaded decoder: Stop the worker threads on errors.
Lasse Collin [Mon, 24 Oct 2022 13:25:09 +0000 (16:25 +0300)] 
liblzma: Threaded decoder: Stop the worker threads on errors.

It's waste of CPU time and electricity to leave the unfinished
worker threads running when it is known that their output will
get ignored.

2 years agotuklib_cpucores: Use HW_NCPUONLINE on OpenBSD.
Lasse Collin [Thu, 20 Oct 2022 17:22:50 +0000 (20:22 +0300)] 
tuklib_cpucores: Use HW_NCPUONLINE on OpenBSD.

On OpenBSD the number of cores online is often less
than what HW_NCPU would return because OpenBSD disables
simultaneous multi-threading (SMT) by default.

Thanks to Christian Weisgerber.

2 years agoTests: Skip tests in test_*.sh if encoders and/or decoders are disabled.
Lasse Collin [Wed, 19 Oct 2022 16:39:35 +0000 (19:39 +0300)] 
Tests: Skip tests in test_*.sh if encoders and/or decoders are disabled.

This isn't perfect as the scripts can still fail if only
certain filters are disabled. This is still an improvement
as now "make check" has better behavior when all encoders
or decoders are disabled.

Grepping ../config.h is simple and fairly clean but it only
works if config.h was created. CMake builds don't create
config.h but they don't use these test scripts either.

Thanks to Sebastian Andrzej Siewior for reporting the problem.
Thanks to Jia Tan for the original patch which grepped xz
error messages instead of config.h.

2 years agoTest: Remove the (exit 1) lines.
Lasse Collin [Wed, 19 Oct 2022 15:54:34 +0000 (18:54 +0300)] 
Test: Remove the (exit 1) lines.

I suspect that I used these in the original version because
Autoconf's manual describes that such a trick is needed in
some specific situations for portability reasons. None of those
situations listed on Autoconf 2.71 manual apply to these test
scripts though so this cleans them up.

2 years agoTests: Fix a warning in test_memlimit.c when decoders are disabled.
Lasse Collin [Wed, 19 Oct 2022 14:14:57 +0000 (17:14 +0300)] 
Tests: Fix a warning in test_memlimit.c when decoders are disabled.

2 years agoTests: Add test_memlimit to .gitignore.
Lasse Collin [Wed, 19 Oct 2022 14:11:46 +0000 (17:11 +0300)] 
Tests: Add test_memlimit to .gitignore.

Thanks to Jia Tan.

2 years agoTests: Refactor test_stream_flags.c.
Jia Tan [Thu, 6 Oct 2022 18:53:09 +0000 (21:53 +0300)] 
Tests: Refactor test_stream_flags.c.

Converts test_stream_flags to tuktest. Also the test will now
compile and skip properly if encoders or decoders are disabled.

Thanks to Sebastian Andrzej Siewior.

2 years agoTests: Refactor test_block_header.c.
Jia Tan [Thu, 6 Oct 2022 09:00:38 +0000 (17:00 +0800)] 
Tests: Refactor test_block_header.c.

test_block_header now achieves higher test coverage. Also the
test will now compile and skip properly if encoders or decoders
are disabled.

Thanks to Sebastian Andrzej Siewior.

2 years agoTests: Fix compilation issues.
Jia Tan [Wed, 5 Oct 2022 15:54:12 +0000 (23:54 +0800)] 
Tests: Fix compilation issues.

test_bcj_exact_size, test_check, test_hardware, and test_index will
all now compile and skip properly if encoders or decoders are disabled.

Also fixed a small typo (disabed -> disabled).

Thanks to Sebastian Andrzej Siewior.

2 years agoTests: Include mythread.h in the tests that use MYTHREAD_ENABLED.
Lasse Collin [Wed, 5 Oct 2022 13:20:47 +0000 (16:20 +0300)] 
Tests: Include mythread.h in the tests that use MYTHREAD_ENABLED.

2 years agoliblzma: Fix a compilation issue when encoders are disabled.
Jia Tan [Wed, 5 Oct 2022 12:57:16 +0000 (20:57 +0800)] 
liblzma: Fix a compilation issue when encoders are disabled.

When encoders were disabled and threading enabled, outqueue.c and
outqueue.h were not compiled. The multi threaded decoder required
these files, so compilation failed.

2 years agoTests: Fix compilation error when threading support has been disabled.
Jia Tan [Wed, 5 Oct 2022 08:41:38 +0000 (16:41 +0800)] 
Tests: Fix compilation error when threading support has been disabled.

Now tests that require threading are skipped when threading
support has been disabled.

Thanks to Sebastian Andrzej Siewior.

2 years agotuklib_integer: Add 64-bit endianness-converting reads and writes.
Lasse Collin [Wed, 5 Oct 2022 11:26:00 +0000 (14:26 +0300)] 
tuklib_integer: Add 64-bit endianness-converting reads and writes.

Also update the comment in liblzma's memcmplen.h.

Thanks to Michał Górny for the original patch for the reads.

2 years agoliblzma: Add API doc note about the .xz decoder LZMA_MEMLIMIT_ERROR bug.
Lasse Collin [Fri, 30 Sep 2022 09:06:13 +0000 (12:06 +0300)] 
liblzma: Add API doc note about the .xz decoder LZMA_MEMLIMIT_ERROR bug.

The bug was fixed in 660739f99ab211edec4071de98889fb32ed04e98.

2 years agoliblzma: Add dest and src NULL checks to lzma_index_cat.
Jia Tan [Wed, 21 Sep 2022 08:15:50 +0000 (16:15 +0800)] 
liblzma: Add dest and src NULL checks to lzma_index_cat.

The documentation states LZMA_PROG_ERROR can be returned from
lzma_index_cat. Previously, lzma_index_cat could not return
LZMA_PROG_ERROR. Now, the validation is similar to
lzma_index_append, which does a NULL check on the index
parameter.

2 years agoTests: Create a test for the lzma_index_cat bug.
Jia Tan [Wed, 21 Sep 2022 12:29:28 +0000 (20:29 +0800)] 
Tests: Create a test for the lzma_index_cat bug.

2 years agoliblzma: Fix copying of check type statistics in lzma_index_cat().
Jia Tan [Wed, 21 Sep 2022 11:28:53 +0000 (19:28 +0800)] 
liblzma: Fix copying of check type statistics in lzma_index_cat().

The check type of the last Stream in dest was never copied to
dest->checks (the code tried to copy it but it was done too late).
This meant that the value returned by lzma_index_checks() would
only include the check type of the last Stream when multiple
lzma_indexes had been concatenated.

In xz --list this meant that the summary would only list the
check type of the last Stream, so in this sense this was only
a visual bug. However, it's possible that some applications
use this information for purposes other than merely showing
it to the users in an informational message. I'm not aware of
such applications though and it's quite possible that such
applications don't exist.

Regular streamed decompression in xz or any other application
doesn't use lzma_index_cat() and so this bug cannot affect them.

2 years agotuklib_physmem: Fix Unicode builds on Windows.
Lasse Collin [Wed, 28 Sep 2022 09:20:41 +0000 (12:20 +0300)] 
tuklib_physmem: Fix Unicode builds on Windows.

Thanks to ArSaCiA Game.

2 years agoTests: Add test_memlimit.c to test restarting after LZMA_MEMLIMIT_ERROR.
Lasse Collin [Wed, 28 Sep 2022 08:12:07 +0000 (11:12 +0300)] 
Tests: Add test_memlimit.c to test restarting after LZMA_MEMLIMIT_ERROR.

2 years agoliblzma: Stream decoder: Fix restarting after LZMA_MEMLIMIT_ERROR.
Lasse Collin [Wed, 28 Sep 2022 08:05:15 +0000 (11:05 +0300)] 
liblzma: Stream decoder: Fix restarting after LZMA_MEMLIMIT_ERROR.

If lzma_code() returns LZMA_MEMLIMIT_ERROR it is now possible
to use lzma_memlimit_set() to increase the limit and continue
decoding. This was supposed to work from the beginning but
there was a bug. With other decoders (.lzma or threaded .xz)
this already worked correctly.

2 years agoliblzma: Stream decoder: Fix comments.
Lasse Collin [Wed, 28 Sep 2022 08:00:23 +0000 (11:00 +0300)] 
liblzma: Stream decoder: Fix comments.

2 years agoliblzma: ARM64: Add comments.
Lasse Collin [Tue, 20 Sep 2022 13:58:22 +0000 (16:58 +0300)] 
liblzma: ARM64: Add comments.

2 years agoliblzma: ARM64: Fix wrong comment in API doc.
Lasse Collin [Tue, 20 Sep 2022 13:27:50 +0000 (16:27 +0300)] 
liblzma: ARM64: Fix wrong comment in API doc.

Thanks to Jia Tan.

2 years agoxz: Add --experimental-arm64[=width=WIDTH].
Lasse Collin [Mon, 19 Sep 2022 17:24:26 +0000 (20:24 +0300)] 
xz: Add --experimental-arm64[=width=WIDTH].

It will be renamed to --arm64 once it is stable.

Man page or --long-help weren't updated yet.

2 years agoliblzma: Add experimental ARM64 BCJ filter with a temporary Filter ID.
Lasse Collin [Mon, 19 Sep 2022 16:34:56 +0000 (19:34 +0300)] 
liblzma: Add experimental ARM64 BCJ filter with a temporary Filter ID.

That is, the Filter ID will be changed once the design is final.
The current version will be removed. So files created with the
tempoary Filter ID won't be supported in the future.

2 years agoliblzma: Simple/BCJ filters: Allow disabling generic BCJ options.
Lasse Collin [Sat, 17 Sep 2022 19:42:18 +0000 (22:42 +0300)] 
liblzma: Simple/BCJ filters: Allow disabling generic BCJ options.

This will be needed for the ARM64 BCJ filter as it will use
its own options struct.

2 years agoTests: Add a test file for lzma_index_append() integer overflow bug.
Lasse Collin [Fri, 16 Sep 2022 14:08:53 +0000 (17:08 +0300)] 
Tests: Add a test file for lzma_index_append() integer overflow bug.

This test fails before commit 18d7facd3802b55c287581405c4d49c98708c136.

test_files.sh now runs xz -l for bad-3-index-uncomp-overflow.xz
because only then the previously-buggy code path gets tested.
Normal decompression doesn't use lzma_index_append() at all.
Instead, lzma_index_hash functions are used and those already
did the overflow check.

2 years agoTranslations: Add Turkish translation.
Lasse Collin [Fri, 16 Sep 2022 12:10:07 +0000 (15:10 +0300)] 
Translations: Add Turkish translation.

2 years agoUpdate THANKS.
Lasse Collin [Fri, 16 Sep 2022 11:09:07 +0000 (14:09 +0300)] 
Update THANKS.

2 years agoxzgrep: Fix compatibility with old shells.
Lasse Collin [Fri, 16 Sep 2022 11:07:03 +0000 (14:07 +0300)] 
xzgrep: Fix compatibility with old shells.

Running the current xzgrep on Slackware 10.1 with GNU bash 3.00.15:

    xzgrep: line 231: syntax error near unexpected token `;;'

On SCO OpenServer 5.0.7 with Korn Shell 93r:

    syntax error at line 231 : `;;' unexpected

Turns out that some old shells don't like apostrophes (') inside
command substitutions. For example, the following fails:

    x=$(echo foo
    # asdf'zxcv
    echo bar)
    printf '%s\n' "$x"

The problem was introduced by commits
69d1b3fc29677af8ade8dc15dba83f0589cb63d6 (2022-03-29),
bd7b290f3fe4faeceb7d3497ed9bf2e6ed5e7dc5 (2022-07-18), and
a648978b20495b7aa4a8b029c5a810b5ad9d08ff (2022-07-19).
5.2.6 is the only stable release that included
this problem.

Thanks to Kevin R. Bulgrien for reporting the problem
on SCO OpenServer 5.0.7 and for providing the fix.

2 years agoTests: Silence warnings about unused functions from tuktest.h.
Lasse Collin [Fri, 9 Sep 2022 11:12:30 +0000 (14:12 +0300)] 
Tests: Silence warnings about unused functions from tuktest.h.

Warnings about unused tuktest_run_test conveniently tell which
test programs haven't been converted to tuktest.h yet but I
silenced that warning too for now anyway.

It is fine to use __attribute__((__unused__)) even when the
function is actually used because the attribute only means
that the function might be unused.

2 years agoliblzma: lzma_filters_copy: Keep dest[] unmodified if an error occurs.
Lasse Collin [Fri, 9 Sep 2022 10:51:57 +0000 (13:51 +0300)] 
liblzma: lzma_filters_copy: Keep dest[] unmodified if an error occurs.

lzma_stream_encoder() and lzma_stream_encoder_mt() always assumed
this. Before this patch, failing lzma_filters_copy() could result
in free(invalid_pointer) or invalid memory reads in stream_encoder.c
or stream_encoder_mt.c.

To trigger this, allocating memory for a filter options structure
has to fail. These are tiny allocations so in practice they very
rarely fail.

Certain badness in the filter chain array could also make
lzma_filters_copy() fail but both stream_encoder.c and
stream_encoder_mt.c validate the filter chain before
trying to copy it, so the crash cannot occur this way.

2 years agoliblzma: lzma_index_append: Add missing integer overflow check.
Jia Tan [Fri, 2 Sep 2022 12:18:55 +0000 (20:18 +0800)] 
liblzma: lzma_index_append: Add missing integer overflow check.

The documentation in src/liblzma/api/lzma/index.h suggests that
both the unpadded (compressed) size and the uncompressed size
are checked for overflow, but only the unpadded size was checked.
The uncompressed check is done first since that is more likely to
occur than the unpadded or index field size overflows.

2 years agoUpdate THANKS.
Lasse Collin [Thu, 8 Sep 2022 12:11:08 +0000 (15:11 +0300)] 
Update THANKS.

2 years agoCMake: Clarify a comment about Windows symlinks without file extension.
Jia Tan [Thu, 8 Sep 2022 12:07:00 +0000 (15:07 +0300)] 
CMake: Clarify a comment about Windows symlinks without file extension.

2 years agoCMake: Update for liblzma_*.map files and fix wrong common_w32res.rc dep.
Lasse Collin [Thu, 8 Sep 2022 12:02:41 +0000 (15:02 +0300)] 
CMake: Update for liblzma_*.map files and fix wrong common_w32res.rc dep.

The previous commit split liblzma.map into liblzma_linux.map and
liblzma_generic.map. This commit updates the CMake build for those.

common_w32res.rc dependency was listed under Linux/FreeBSD while
obviously it belongs to Windows when building a DLL.

2 years agoliblzma: Vaccinate against an ill patch from RHEL/CentOS 7.
Lasse Collin [Sun, 4 Sep 2022 20:23:00 +0000 (23:23 +0300)] 
liblzma: Vaccinate against an ill patch from RHEL/CentOS 7.

RHEL/CentOS 7 shipped with 5.1.2alpha, including the threaded
encoder that is behind #ifdef LZMA_UNSTABLE in the API headers.
In 5.1.2alpha these symbols are under XZ_5.1.2alpha in liblzma.map.
API/ABI compatibility tracking isn't done between development
releases so newer releases didn't have XZ_5.1.2alpha anymore.

Later RHEL/CentOS 7 updated xz to 5.2.2 but they wanted to keep
the exported symbols compatible with 5.1.2alpha. After checking
the ABI changes it turned out that >= 5.2.0 ABI is backward
compatible with the threaded encoder functions from 5.1.2alpha
(but not vice versa as fixes and extensions to these functions
were made between 5.1.2alpha and 5.2.0).

In RHEL/CentOS 7, XZ Utils 5.2.2 was patched with
xz-5.2.2-compat-libs.patch to modify liblzma.map:

  - XZ_5.1.2alpha was added with lzma_stream_encoder_mt and
    lzma_stream_encoder_mt_memusage. This matched XZ Utils 5.1.2alpha.

  - XZ_5.2 was replaced with XZ_5.2.2. It is clear that this was
    an error; the intention was to keep using XZ_5.2 (XZ_5.2.2
    has never been used in XZ Utils). So XZ_5.2.2 lists all
    symbols that were listed under XZ_5.2 before the patch.
    lzma_stream_encoder_mt and _mt_memusage are included too so
    they are listed both here and under XZ_5.1.2alpha.

The patch didn't add any __asm__(".symver ...") lines to the .c
files. Thus the resulting liblzma.so exports the threaded encoder
functions under XZ_5.1.2alpha only. Listing the two functions
also under XZ_5.2.2 in liblzma.map has no effect without
matching .symver lines.

The lack of XZ_5.2 in RHEL/CentOS 7 means that binaries linked
against unpatched XZ Utils 5.2.x won't run on RHEL/CentOS 7.
This is unfortunate but this alone isn't too bad as the problem
is contained within RHEL/CentOS 7 and doesn't affect users
of other distributions. It could also be fixed internally in
RHEL/CentOS 7.

The second problem is more serious: In XZ Utils 5.2.2 the API
headers don't have #ifdef LZMA_UNSTABLE for obvious reasons.
This is true in RHEL/CentOS 7 version too. Thus now programs
using new APIs can be compiled without an extra #define. However,
the programs end up depending on symbol version XZ_5.1.2alpha
(and possibly also XZ_5.2.2) instead of XZ_5.2 as they would
with an unpatched XZ Utils 5.2.2. This means that such binaries
won't run on other distributions shipping XZ Utils >= 5.2.0 as
they don't provide XZ_5.1.2alpha or XZ_5.2.2; they only provide
XZ_5.2 (and XZ_5.0). (This includes RHEL/CentOS 8 as the patch
luckily isn't included there anymore with XZ Utils 5.2.4.)

Binaries built by RHEL/CentOS 7 users get distributed and then
people wonder why they don't run on some other distribution.
Seems that people have found out about the patch and been copying
it to some build scripts, seemingly curing the symptoms but
actually spreading the illness further and outside RHEL/CentOS 7.

The ill patch seems to be from late 2016 (RHEL 7.3) and in 2017 it
had spread at least to EasyBuild. I heard about the events only
recently. :-(

This commit splits liblzma.map into two versions: one for
GNU/Linux and another for other OSes that can use symbol versioning
(FreeBSD, Solaris, maybe others). The Linux-specific file and the
matching additions to .c files add full compatibility with binaries
that have been built against a RHEL/CentOS-patched liblzma. Builds
for OSes other than GNU/Linux won't get the vaccine as they should
be immune to the problem (I really hope that no build script uses
the RHEL/CentOS 7 patch outside GNU/Linux).

The RHEL/CentOS compatibility symbols XZ_5.1.2alpha and XZ_5.2.2
are intentionally put *after* XZ_5.2 in liblzma_linux.map. This way
if one forgets to #define HAVE_SYMBOL_VERSIONS_LINUX when building,
the resulting liblzma.so.5 will have lzma_stream_encoder_mt@@XZ_5.2
since XZ_5.2 {...} is the first one that lists that function.
Without HAVE_SYMBOL_VERSIONS_LINUX @XZ_5.1.2alpha and @XZ_5.2.2
will be missing but that's still a minor problem compared to
only having lzma_stream_encoder_mt@@XZ_5.1.2alpha!

The "local: *;" line was moved to XZ_5.0 so that it doesn't need
to be moved around. It doesn't matter where it is put.

Having two similar liblzma_*.map files is a bit silly as it is,
at least for now, easily possible to generate the generic one
from the Linux-specific file. But that adds extra steps and
increases the risk of mistakes when supporting more than one
build system. So I rather maintain two files in parallel and let
validate_map.sh check that they are in sync when "make mydist"
is run.

This adds .symver lines for lzma_stream_encoder_mt@XZ_5.2.2 and
lzma_stream_encoder_mt_memusage@XZ_5.2.2 even though these
weren't exported by RHEL/CentOS 7 (only @@XZ_5.1.2alpha was
for these two). I added these anyway because someone might
misunderstand the RHEL/CentOS 7 patch and think that @XZ_5.2.2
(@@XZ_5.2.2) versions were exported too.

At glance one could suggest using __typeof__ to copy the function
prototypes when making aliases. However, this doesn't work trivially
because __typeof__ won't copy attributes (lzma_nothrow, lzma_pure)
and it won't change symbol visibility from hidden to default (done
by LZMA_API()). Attributes could be copied with __copy__ attribute
but that needs GCC 9 and a fallback method would be needed anyway.

This uses __symver__ attribute with GCC >= 10 and
__asm__(".symver ...") with everything else. The attribute method
is required for LTO (-flto) support with GCC. Using -flto with
GCC older than 10 is now broken on GNU/Linux and will not be fixed
(can silently result in a broken liblzma build that has dangerously
incorrect symbol versions). LTO builds with Clang seem to work
with the traditional __asm__(".symver ...") method.

Thanks to Boud Roukema for reporting the problem and discussing
the details and testing the fix.

2 years agoCMake: Add xz symlinks.
Lasse Collin [Wed, 31 Aug 2022 13:42:04 +0000 (16:42 +0300)] 
CMake: Add xz symlinks.

These are a minor thing especially since the xz build has
some real problems still like lack of large file support
on 32-bit systems but I'll commit this since the code exists.

Thanks to Jia Tan.

2 years agoCMake: Put xz man page install under if(UNIX) like is for xzdec.
Lasse Collin [Wed, 31 Aug 2022 13:29:38 +0000 (16:29 +0300)] 
CMake: Put xz man page install under if(UNIX) like is for xzdec.

Thanks to Jia Tan.

3 years agoBump version number for 5.3.3alpha. v5.3.3alpha
Lasse Collin [Mon, 22 Aug 2022 15:16:40 +0000 (18:16 +0300)] 
Bump version number for 5.3.3alpha.

3 years agoAdd NEWS for 5.3.3alpha.
Lasse Collin [Mon, 22 Aug 2022 15:13:56 +0000 (18:13 +0300)] 
Add NEWS for 5.3.3alpha.

3 years agoTranslations: Add Portuguese translation.
Lasse Collin [Tue, 12 Jul 2022 14:59:41 +0000 (17:59 +0300)] 
Translations: Add Portuguese translation.

Jia Tan made white-space changes and also changed "Language: pt_BR\n"
to pt. The translator wasn't reached so I'm hoping these changes
are OK and will commit it without translator's approval.

Thanks to Pedro Albuquerque and Jia Tan.

3 years agoTranslations: Add Serbian translation.
Lasse Collin [Sun, 10 Jul 2022 18:16:40 +0000 (21:16 +0300)] 
Translations: Add Serbian translation.

Quite a few white-space changes were made by Jia Tan to make
this look good. Contacting the translator didn't succeed so
I'm committing this without getting translator's approval.

Thanks to Мирослав Николић (Miroslav Nikolic) and Jia Tan.