]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
3 years agoTranslations: Add Swedish translation.
Lasse Collin [Mon, 4 Jul 2022 20:51:36 +0000 (23:51 +0300)] 
Translations: Add Swedish translation.

Thanks to Sebastian Rasmussen and Jia Tan.

3 years agoTranslations: Add Esperanto translation.
Lasse Collin [Mon, 4 Jul 2022 20:40:27 +0000 (23:40 +0300)] 
Translations: Add Esperanto translation.

Thanks to Keith Bowes and Jia Tan.

3 years agoTranslations: Add Catalan translation.
Lasse Collin [Thu, 30 Jun 2022 21:22:33 +0000 (00:22 +0300)] 
Translations: Add Catalan translation.

Thanks to Jordi Mas and Jia Tan.

3 years agoTranslations: Add Ukrainian translation.
Lasse Collin [Thu, 30 Jun 2022 14:47:08 +0000 (17:47 +0300)] 
Translations: Add Ukrainian translation.

Thanks to Yuri Chornoivan and Jia Tan.

3 years agoTranslators: Add Romanian translation.
Lasse Collin [Thu, 30 Jun 2022 14:45:26 +0000 (17:45 +0300)] 
Translators: Add Romanian translation.

Thanks to Remus-Gabriel Chelu and Jia Tan.

3 years agoTranslations: Update Brazilian Portuguese translation.
Lasse Collin [Wed, 29 Jun 2022 15:33:32 +0000 (18:33 +0300)] 
Translations: Update Brazilian Portuguese translation.

One msgstr was changed. The diff is long due to changes
in the source code line numbers in the comments.

Thanks to Rafael Fontenelle.

3 years agoTranslations: Add Croatian translation.
Lasse Collin [Wed, 29 Jun 2022 15:04:44 +0000 (18:04 +0300)] 
Translations: Add Croatian translation.

Thanks to Božidar Putanec and Jia Tan.

3 years agoTranslations: Add Spanish translation.
Lasse Collin [Wed, 29 Jun 2022 14:58:48 +0000 (17:58 +0300)] 
Translations: Add Spanish translation.

Thanks to Cristian Othón Martínez Vera and Jia Tan.

3 years agoTranslations: Add Korean translation.
Lasse Collin [Wed, 29 Jun 2022 14:49:43 +0000 (17:49 +0300)] 
Translations: Add Korean translation.

Thanks to Seong-ho Cho and Jia Tan.

3 years agoTranslations: Rebuild cs.po to avoid incorrect fuzzy strings.
Lasse Collin [Mon, 16 Mar 2020 19:57:21 +0000 (21:57 +0200)] 
Translations: Rebuild cs.po to avoid incorrect fuzzy strings.

"make dist" updates the .po files and the fuzzy strings would
result in multiple very wrong translations.

3 years agoTranslations: Add partial Danish translation.
Lasse Collin [Mon, 16 Mar 2020 15:30:39 +0000 (17:30 +0200)] 
Translations: Add partial Danish translation.

I made a few minor white space changes without getting them
approved by the Danish translation team.

3 years agoTranslations: Add hu, zh_CN, and zh_TW.
Lasse Collin [Wed, 11 Mar 2020 20:37:54 +0000 (22:37 +0200)] 
Translations: Add hu, zh_CN, and zh_TW.

I made a few white space changes to these without getting them
approved by the translation teams. (I tried to contact the hu and
zh_TW teams but didn't succeed. I didn't contact the zh_CN team.)

3 years agoTranslations: Update vi.po to match the file from the TP.
Lasse Collin [Wed, 11 Mar 2020 12:33:30 +0000 (14:33 +0200)] 
Translations: Update vi.po to match the file from the TP.

The translated strings haven't been updated but word wrapping
is different.

3 years agoTranslations: Add fi and pt_BR, and update de, fr, it, and pl.
Lasse Collin [Wed, 11 Mar 2020 12:18:03 +0000 (14:18 +0200)] 
Translations: Add fi and pt_BR, and update de, fr, it, and pl.

The German translation isn't identical to the file in
the Translation Project but the changes (white space changes
only) were approved by the translator Mario Blättermann.

3 years agoxz: Try to clarify --memlimit-mt-decompress vs. --memlimit-compress.
Lasse Collin [Mon, 22 Aug 2022 14:27:19 +0000 (17:27 +0300)] 
xz: Try to clarify --memlimit-mt-decompress vs. --memlimit-compress.

3 years agoCMake: Add liblzma tests.
Lasse Collin [Mon, 22 Aug 2022 13:46:18 +0000 (16:46 +0300)] 
CMake: Add liblzma tests.

Thanks to Jia Tan for the patch.

3 years agoxz: Revise --info-memory output.
Lasse Collin [Fri, 19 Aug 2022 20:32:22 +0000 (23:32 +0300)] 
xz: Revise --info-memory output.

The strings could be more descriptive but it's good
to have some version of this committed now.

--robot mode wasn't changed yet.

3 years agoxz: Update the man page for threaded decompression and memlimits.
Lasse Collin [Fri, 19 Aug 2022 20:12:02 +0000 (23:12 +0300)] 
xz: Update the man page for threaded decompression and memlimits.

This documents the changes made in commits
6c6da57ae2aa962aabde6892442227063d87e88c,
cad299008cf73ec566f0662a9cf2b94f86a99659, and
898faa97287a756231c663a3ed5165672b417207.

The --info-memory bit hasn't been finished yet
even though it's already mentioned in this commit
under --memlimit-mt-decompress and --threads.

3 years agoBuild: Include the CMake files in the distribution.
Lasse Collin [Thu, 18 Aug 2022 14:49:16 +0000 (17:49 +0300)] 
Build: Include the CMake files in the distribution.

This was supposed to be done in 2020 with 5.2.5 release
already but it was noticed only today. 5.2.5 and 5.2.6
even mention experiemental CMake support in the NEWS entries.

Thanks to Olivier B. for reporting the problem.

3 years agoWindows: Fix broken liblzma.dll build with Visual Studio project files.
Lasse Collin [Thu, 18 Aug 2022 14:38:05 +0000 (17:38 +0300)] 
Windows: Fix broken liblzma.dll build with Visual Studio project files.

The bug was introduced in 352ba2d69af2136bc814aa1df1a132559d445616
"Windows: Fix building of resource files when config.h isn't used."

That commit fixed liblzma.dll build with CMake while keeping it
working with Autotools on Windows but the VS project files were
forgotten.

I haven't tested these changes.

Thanks to Olivier B. for reporting the bug and for the initial patch.

3 years agoliblzma: Threaded decoder: Improve LZMA_FAIL_FAST when LZMA_FINISH is used.
Lasse Collin [Thu, 18 Aug 2022 14:16:49 +0000 (17:16 +0300)] 
liblzma: Threaded decoder: Improve LZMA_FAIL_FAST when LZMA_FINISH is used.

It will now return LZMA_DATA_ERROR (not LZMA_OK or LZMA_BUF_ERROR)
if LZMA_FINISH is used and there isn't enough input to finish
decoding the Block Header or the Block. The use of LZMA_DATA_ERROR
is simpler and the less risky than LZMA_BUF_ERROR but this might
be changed before 5.4.0.

3 years agoAdd NEWS for 5.2.6.
Lasse Collin [Fri, 12 Aug 2022 15:31:47 +0000 (18:31 +0300)] 
Add NEWS for 5.2.6.

3 years agoAdd Jia Tan to AUTHORS.
Lasse Collin [Fri, 12 Aug 2022 11:28:41 +0000 (14:28 +0300)] 
Add Jia Tan to AUTHORS.

3 years agoBuild: Start the generated ChangeLog from around 5.2.0 instead of 5.0.0.
Lasse Collin [Mon, 25 Jul 2022 16:28:26 +0000 (19:28 +0300)] 
Build: Start the generated ChangeLog from around 5.2.0 instead of 5.0.0.

This makes ChangeLog smaller.

3 years agoTranslations: Change the copyright comment string to use with po4a.
Lasse Collin [Mon, 25 Jul 2022 16:11:05 +0000 (19:11 +0300)] 
Translations: Change the copyright comment string to use with po4a.

This affects the second line in po4a/xz-man.pot. The man pages of
xzdiff, xzgrep, and xzmore are from GNU gzip and under GNU GPLv2+
while the rest of the man pages are in the public domain.

3 years agoliblzma: Refactor lzma_mf_is_supported() to use a switch-statement.
Jia Tan [Mon, 25 Jul 2022 15:30:05 +0000 (18:30 +0300)] 
liblzma: Refactor lzma_mf_is_supported() to use a switch-statement.

3 years agoBuild: Don't allow empty LIST in --enable-match-finders=LIST.
Jia Tan [Mon, 25 Jul 2022 15:20:01 +0000 (18:20 +0300)] 
Build: Don't allow empty LIST in --enable-match-finders=LIST.

It's enforced only when a match finder is needed, that is,
when LZMA1 or LZMA2 encoder is enabled.

3 years agoxz: Update the man page that change to --keep will be in 5.2.6.
Lasse Collin [Sun, 24 Jul 2022 10:27:48 +0000 (13:27 +0300)] 
xz: Update the man page that change to --keep will be in 5.2.6.

3 years agoUpdate THANKS.
Lasse Collin [Tue, 19 Jul 2022 20:23:54 +0000 (23:23 +0300)] 
Update THANKS.

3 years agoCMake: Add missing source file to liblzma build
Nicholas Jackson [Mon, 18 Jul 2022 00:39:23 +0000 (17:39 -0700)] 
CMake: Add missing source file to liblzma build

3 years agoxzgrep man page: Document exit statuses.
Lasse Collin [Tue, 19 Jul 2022 20:19:49 +0000 (23:19 +0300)] 
xzgrep man page: Document exit statuses.

3 years agoxzgrep: Improve error handling, especially signals.
Lasse Collin [Tue, 19 Jul 2022 20:13:24 +0000 (23:13 +0300)] 
xzgrep: Improve error handling, especially signals.

xzgrep wouldn't exit on SIGPIPE or SIGQUIT when it clearly
should have. It's quite possible that it's not perfect still
but at least it's much better.

If multiple exit statuses compete, now it tries to pick
the largest of value.

Some comments were added.

The exit status handling of signals is still broken if the shell
uses values larger than 255 in $? to indicate that a process
died due to a signal ***and*** their "exit" command doesn't take
this into account. This seems to work well with the ksh and yash
versions I tried. However, there is a report in gzip/zgrep that
OpenSolaris 5.11 (not 5.10) has a problem with "exit" truncating
the argument to 8 bits:

    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22900#25

Such a bug would break xzgrep but I didn't add a workaround
at least for now. 5.11 is old and I don't know if the problem
exists in modern descendants, or if the problem exists in other
ksh implementations in use.

3 years agoxzgrep: Make the fix for ZDI-CAN-16587 more robust.
Lasse Collin [Mon, 18 Jul 2022 21:10:55 +0000 (00:10 +0300)] 
xzgrep: Make the fix for ZDI-CAN-16587 more robust.

I don't know if this can make a difference in the real world
but it looked kind of suspicious (what happens with sed
implementations that cannot process very long lines?).
At least this commit shouldn't make it worse.

3 years agoxzgrep: Use grep -H --label when available (GNU, *BSDs).
Lasse Collin [Mon, 18 Jul 2022 18:52:31 +0000 (21:52 +0300)] 
xzgrep: Use grep -H --label when available (GNU, *BSDs).

It avoids the use of sed for prefixing filenames to output lines.
Using sed for that is slower and prone to security bugs so now
the sed method is only used as a fallback.

This also fixes an actual bug: When grepping a binary file,
GNU grep nowadays prints its diagnostics to stderr instead of
stdout and thus the sed-method for prefixing the filename doesn't
work. So with this commit grepping binary files gives reasonable
output with GNU grep now.

This was inspired by zgrep but the implementation is different.

3 years agoxzgrep: Use -e to specify the pattern to grep.
Lasse Collin [Mon, 18 Jul 2022 18:10:25 +0000 (21:10 +0300)] 
xzgrep: Use -e to specify the pattern to grep.

Now we don't need the separate test for adding the -q option
as it can be added directly in the two places where it's needed.

3 years agoScripts: Use printf instead of echo in a few places.
Lasse Collin [Mon, 18 Jul 2022 16:18:48 +0000 (19:18 +0300)] 
Scripts: Use printf instead of echo in a few places.

It's a good habbit as echo has some portability corner cases
when the string contents can be anything.

3 years agoxzgrep: Add more LC_ALL=C to avoid bugs with multibyte characters.
Lasse Collin [Sun, 17 Jul 2022 18:36:25 +0000 (21:36 +0300)] 
xzgrep: Add more LC_ALL=C to avoid bugs with multibyte characters.

Also replace one use of expr with printf.

The rationale for LC_ALL=C was already mentioned in
69d1b3fc29677af8ade8dc15dba83f0589cb63d6 that fixed a security
issue. However, unrelated uses weren't changed in that commit yet.

POSIX says that with sed and such tools one should use LC_ALL=C
to ensure predictable behavior when strings contain byte sequences
that aren't valid multibyte characters in the current locale. See
under "Application usage" in here:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

With GNU sed invalid multibyte strings would work without this;
it's documented in its Texinfo manual. Some other implementations
aren't so forgiving.

3 years agoxzgrep: Fix parsing of certain options.
Lasse Collin [Sun, 17 Jul 2022 17:55:16 +0000 (20:55 +0300)] 
xzgrep: Fix parsing of certain options.

Fix handling of "xzgrep -25 foo" (in GNU grep "grep -25 foo" is
an alias for "grep -C25 foo"). xzgrep would treat "foo" as filename
instead of as a pattern. This bug was fixed in zgrep in gzip in 2012.

Add -E, -F, -G, and -P to the "no argument required" list.

Add -X to "argument required" list. It is an
intentionally-undocumented GNU grep option so this isn't
an important option for xzgrep but it seems that other grep
implementations (well, those that I checked) don't support -X
so I hope this change is an improvement still.

grep -d (grep --directories=ACTION) requires an argument. In
contrast to zgrep, I kept -d in the "no argument required" list
because it's not supported in xzgrep (or zgrep). This way
"xzgrep -d" gives an error about option being unsupported instead
of telling that it requires an argument. Both zgrep and xzgrep
tell that it's unsupported if an argument is specified.

Add comments.

3 years agoTests: Add the .lzma files to test_files.sh.
Lasse Collin [Thu, 14 Jul 2022 17:33:05 +0000 (20:33 +0300)] 
Tests: Add the .lzma files to test_files.sh.

3 years agoTests: Add .lzma test files.
Lasse Collin [Thu, 14 Jul 2022 16:37:42 +0000 (19:37 +0300)] 
Tests: Add .lzma test files.

3 years agoliblzma: Rename a variable and improve a comment.
Lasse Collin [Thu, 14 Jul 2022 15:12:38 +0000 (18:12 +0300)] 
liblzma: Rename a variable and improve a comment.

3 years agoUpdate THANKS.
Lasse Collin [Wed, 13 Jul 2022 19:24:41 +0000 (22:24 +0300)] 
Update THANKS.

3 years agoliblzma: Add optional autodetection of LZMA end marker.
Lasse Collin [Wed, 13 Jul 2022 19:24:07 +0000 (22:24 +0300)] 
liblzma: Add optional autodetection of LZMA end marker.

Turns out that this is needed for .lzma files as the spec in
LZMA SDK says that end marker may be present even if the size
is stored in the header. Such files are rare but exist in the
real world. The code in liblzma is so old that the spec didn't
exist in LZMA SDK back then and I had understood that such
files weren't possible (the lzma tool in LZMA SDK didn't
create such files).

This modifies the internal API so that LZMA decoder can be told
if EOPM is allowed even when the uncompressed size is known.
It's allowed with .lzma and not with other uses.

Thanks to Karl Beldan for reporting the problem.

3 years agoxz: Document the special memlimit case of 2000 MiB on MIPS32.
Lasse Collin [Tue, 12 Jul 2022 15:53:04 +0000 (18:53 +0300)] 
xz: Document the special memlimit case of 2000 MiB on MIPS32.

See commit fc3d3a7296ef58bb799a73943636b8bfd95339f7.

3 years agoCreated script to generate code coverage reports.
Jia Tan [Fri, 1 Jul 2022 13:19:26 +0000 (21:19 +0800)] 
Created script to generate code coverage reports.

The script uses lcov and genhtml after running the tests
to show the code coverage statistics. The script will create
a coverage directory where it is run. It can be run both in
and out of the source directory.

3 years agoTests: Add more tests into test_check.
Jia Tan [Thu, 16 Jun 2022 14:32:19 +0000 (17:32 +0300)] 
Tests: Add more tests into test_check.

3 years agoTests: Use char[][24] array for enum_strings_lzma_ret.
Lasse Collin [Thu, 16 Jun 2022 12:02:57 +0000 (15:02 +0300)] 
Tests: Use char[][24] array for enum_strings_lzma_ret.

Array of pointers to short strings is a bit pointless here
and now it's fully const.

3 years agoTests: tuktest.h: Add tuktest_error_impl to help with error conditions.
Lasse Collin [Thu, 16 Jun 2022 11:12:14 +0000 (14:12 +0300)] 
Tests: tuktest.h: Add tuktest_error_impl to help with error conditions.

3 years agoTests: tuktest.h: Rename file_from_* and use tuktest_malloc there.
Lasse Collin [Thu, 16 Jun 2022 10:29:59 +0000 (13:29 +0300)] 
Tests: tuktest.h: Rename file_from_* and use tuktest_malloc there.

3 years agoTests: tuktest.h: Add malloc wrapper with automatic freeing.
Lasse Collin [Thu, 16 Jun 2022 10:08:19 +0000 (13:08 +0300)] 
Tests: tuktest.h: Add malloc wrapper with automatic freeing.

3 years agoTests: tuktest.h: Move a function.
Lasse Collin [Thu, 16 Jun 2022 08:47:37 +0000 (11:47 +0300)] 
Tests: tuktest.h: Move a function.

3 years agoTests: test_vli: Remove an invalid test-assertion.
Lasse Collin [Tue, 14 Jun 2022 19:21:15 +0000 (22:21 +0300)] 
Tests: test_vli: Remove an invalid test-assertion.

lzma_vli is unsigned so trying a signed value results in
a compiler warning from -Wsign-conversion. (lzma_vli)-1
equals to LZMA_VLI_UNKNOWN anyway which is the next assertion.

3 years agoTests: test_vli: Add const where appropriate.
Lasse Collin [Tue, 14 Jun 2022 19:10:10 +0000 (22:10 +0300)] 
Tests: test_vli: Add const where appropriate.

3 years agoAdded vli tests to .gitignore
Jia Tan [Mon, 13 Jun 2022 12:27:03 +0000 (20:27 +0800)] 
Added vli tests to .gitignore

3 years agoCreated tests for all functions exported in vli.h
Jia Tan [Sun, 12 Jun 2022 03:31:40 +0000 (11:31 +0800)] 
Created tests for all functions exported in vli.h

Achieved 100% code coverage vli_encoder.c, vli_decoder.c, and vli_size.c

3 years agoAdded parallel test artifacts to .gitignore
jiat75 [Fri, 3 Jun 2022 13:24:54 +0000 (21:24 +0800)] 
Added parallel test artifacts to .gitignore

3 years agoTests: Use good-1-empty-bcj-lzma2.xz in test_bcj_exact_size.
Lasse Collin [Tue, 14 Jun 2022 18:29:21 +0000 (21:29 +0300)] 
Tests: Use good-1-empty-bcj-lzma2.xz in test_bcj_exact_size.

It's much nicer this way so that the test data isn't a hardcoded
table inside the C file.

3 years agoTests: Add file reading helpers to tuktest.h.
Lasse Collin [Tue, 14 Jun 2022 18:26:13 +0000 (21:26 +0300)] 
Tests: Add file reading helpers to tuktest.h.

3 years agoTests: tuktest.h: Move a printf from a macro to a helper function.
Lasse Collin [Tue, 14 Jun 2022 15:21:57 +0000 (18:21 +0300)] 
Tests: tuktest.h: Move a printf from a macro to a helper function.

3 years agoTests: Add test file good-1-empty-bcj-lzma2.xz.
Lasse Collin [Tue, 14 Jun 2022 14:20:49 +0000 (17:20 +0300)] 
Tests: Add test file good-1-empty-bcj-lzma2.xz.

This is from test_bcj_exact_size.c.
It's good to have it as a standalone file.

3 years agoTests: Created tests for hardware functions.
Jia Tan [Fri, 10 Jun 2022 13:35:18 +0000 (21:35 +0800)] 
Tests: Created tests for hardware functions.

Created tests for all API functions exported in
src/liblzma/api/lzma/hardware.h. The tests are fairly trivial
but are helpful because they will inform users if their machines
cannot support these functions. They also improve the code
coverage metrics.

3 years agoTests: Convert test_check to tuktest.
Lasse Collin [Thu, 2 Jun 2022 18:01:45 +0000 (21:01 +0300)] 
Tests: Convert test_check to tuktest.

Thanks to Jia Tan for help with all the tests.

3 years agoTests: Convert test_block_header to tuktest.
Lasse Collin [Thu, 2 Jun 2022 17:31:03 +0000 (20:31 +0300)] 
Tests: Convert test_block_header to tuktest.

3 years agoTests: Convert test_bcj_exact_size to tuktest.
Lasse Collin [Thu, 2 Jun 2022 17:28:23 +0000 (20:28 +0300)] 
Tests: Convert test_bcj_exact_size to tuktest.

The compress() and decompress() functions were merged because
the later depends on the former so they need to be a single
test case.

3 years agoTests: Include tuktest.h in tests.h.
Lasse Collin [Thu, 2 Jun 2022 17:27:00 +0000 (20:27 +0300)] 
Tests: Include tuktest.h in tests.h.

This breaks -Werror because none of the tests so far use
tuktest.h and thus there are warnings about unused variables
and functions.

3 years agoTests: Add tuktest.h mini-test-framework.
Lasse Collin [Thu, 2 Jun 2022 17:25:21 +0000 (20:25 +0300)] 
Tests: Add tuktest.h mini-test-framework.

3 years agoBuild: Enable Automake's parallel test harness.
Lasse Collin [Mon, 23 May 2022 18:31:36 +0000 (21:31 +0300)] 
Build: Enable Automake's parallel test harness.

It has been the default for quite some time already and
the old serial harness isn't discouraged. The downside is
that with parallel tests one cannot print progress info or
other diagnostics to the terminal; all output from the tests
will be in the log files only. But now that the compression
tests are separated the parallel tests will speed things up.

3 years agoTests: Split test_compress.sh into separate test unit for each file.
Lasse Collin [Mon, 23 May 2022 18:17:47 +0000 (21:17 +0300)] 
Tests: Split test_compress.sh into separate test unit for each file.

test_compress.sh now takes one command line argument:
a filename to be tested. If it begins with "compress_generated_"
the file will be created with create_compress_files.

This will allow parallel execution of the slow tests.

3 years agoTest: Make create_compress_files.c a little more flexible.
Lasse Collin [Mon, 23 May 2022 17:32:49 +0000 (20:32 +0300)] 
Test: Make create_compress_files.c a little more flexible.

If a command line argument is given, then only the test file
of that type is created. It's quite dumb in sense that unknown
names don't give an error but it's good enough here.

Also use EXIT_FAILURE instead of 1 as exit status for errors.

3 years agoTests: Remove unneeded commented lines from test_compress.sh.
Lasse Collin [Mon, 23 May 2022 17:17:42 +0000 (20:17 +0300)] 
Tests: Remove unneeded commented lines from test_compress.sh.

3 years agoTests: Remove progress indicator from test_compress.sh.
Lasse Collin [Mon, 23 May 2022 17:16:00 +0000 (20:16 +0300)] 
Tests: Remove progress indicator from test_compress.sh.

It will be useless with Automake's parallel tests.

3 years agoliblzma: Silence a warning.
Lasse Collin [Mon, 23 May 2022 16:37:18 +0000 (19:37 +0300)] 
liblzma: Silence a warning.

The actual initialization is done via mythread_sync and seems
that GCC doesn't necessarily see that it gets initialized there.

3 years agoxz: Fix build with --disable-threads.
Lasse Collin [Thu, 14 Apr 2022 17:53:16 +0000 (20:53 +0300)] 
xz: Fix build with --disable-threads.

3 years agoxz: Change the cap of the default -T0 memlimit for 32-bit xz.
Lasse Collin [Thu, 14 Apr 2022 11:50:17 +0000 (14:50 +0300)] 
xz: Change the cap of the default -T0 memlimit for 32-bit xz.

The SIZE_MAX / 3 was 1365 MiB. 1400 MiB gives little more room
and it looks like a round (artificial) number in --info-memory
once --info-memory is made to display it.

Also, using #if avoids useless code on 64-bit builds.

3 years agoxz: Add a default soft memory usage limit for --threads=0.
Lasse Collin [Thu, 14 Apr 2022 11:20:46 +0000 (14:20 +0300)] 
xz: Add a default soft memory usage limit for --threads=0.

This is a soft limit in sense that it only affects the number of
threads. It never makes xz fail and it never makes xz change
settings that would affect the compressed output.

The idea is to make -T0 have more reasonable behavior when
the system has very many cores or when a memory-hungry
compression options are used. This also helps with 32-bit xz,
preventing it from running out of address space.

The downside of this commit is that now the number of threads
might become too low compared to what the user expected. I
hope this to be an acceptable compromise as the old behavior
has been a source of well-argued complaints for a long time.

3 years agoxz: Make -T0 use multithreaded mode on single-core systems.
Lasse Collin [Thu, 14 Apr 2022 09:59:09 +0000 (12:59 +0300)] 
xz: Make -T0 use multithreaded mode on single-core systems.

The main problem withi the old behavior is that the compressed
output is different on single-core systems vs. multicore systems.
This commit fixes it by making -T0 one thread in multithreaded mode
on single-core systems.

The downside of this is that it uses more memory. However, if
--memlimit-compress is used, xz can (thanks to the previous commit)
drop to the single-threaded mode still.

3 years agoxz: Changes to --memlimit-compress and --no-adjust.
Lasse Collin [Thu, 14 Apr 2022 09:38:00 +0000 (12:38 +0300)] 
xz: Changes to --memlimit-compress and --no-adjust.

In single-threaded mode, --memlimit-compress can make xz scale down
the LZMA2 dictionary size to meet the memory usage limit. This
obviously affects the compressed output. However, if xz was in
threaded mode, --memlimit-compress could make xz reduce the number
of threads but it wouldn't make xz switch from multithreaded mode
to single-threaded mode or scale down the LZMA2 dictionary size.
This seemed illogical and there was even a "FIXME?" about it.

Now --memlimit-compress can make xz switch to single-threaded
mode if one thread in multithreaded mode uses too much memory.
If memory usage is still too high, then the LZMA2 dictionary
size can be scaled down too.

The option --no-adjust was also changed so that it no longer
prevents xz from scaling down the number of threads as that
doesn't affect compressed output (only performance). After
this commit --no-adjust only prevents adjustments that affect
compressed output, that is, with --no-adjust xz won't switch
from multithreaded mode to single-threaded mode and won't
scale down the LZMA2 dictionary size.

The man page wasn't updated yet.

3 years agoxz: Add --memlimit-mt-decompress along with a default limit value.
Lasse Collin [Mon, 11 Apr 2022 19:20:49 +0000 (22:20 +0300)] 
xz: Add --memlimit-mt-decompress along with a default limit value.

--memlimit-mt-decompress allows specifying the limit for
multithreaded decompression. This matches memlimit_threading in
liblzma. This limit can only affect the number of threads being
used; it will never prevent xz from decompressing a file. The
old --memlimit-decompress option is still used at the same time.

If the value of --memlimit-decompress (the default value or
one specified by the user) is less than the value of
--memlimit-mt-decompress , then --memlimit-mt-decompress is
reduced to match --memlimit-decompress.

Man page wasn't updated yet.

3 years agoliblzma: Threaded decoder: Improve setting of pending_error.
Lasse Collin [Wed, 6 Apr 2022 20:11:59 +0000 (23:11 +0300)] 
liblzma: Threaded decoder: Improve setting of pending_error.

It doesn't need to be done conditionally. The comments try
to explain it.

3 years agoliblzma: Add a new flag LZMA_FAIL_FAST for threaded decoder.
Lasse Collin [Wed, 6 Apr 2022 09:39:49 +0000 (12:39 +0300)] 
liblzma: Add a new flag LZMA_FAIL_FAST for threaded decoder.

In most cases if the input file is corrupt the application won't
care about the uncompressed content at all. With this new flag
the threaded decoder will return an error as soon as any thread
has detected an error; it won't wait to copy out the data before
the location of the error.

I don't plan to use this in xz to keep the behavior consistent
between single-threaded and multi-threaded modes.

3 years agoliblzma: Threaded decoder: Always wait for output if LZMA_FINISH is used.
Lasse Collin [Tue, 5 Apr 2022 09:24:57 +0000 (12:24 +0300)] 
liblzma: Threaded decoder: Always wait for output if LZMA_FINISH is used.

This makes the behavior consistent with the single-threaded
decoder when handling truncated .xz files.

Thanks to Jia Tan for finding this issue.

3 years agoliblzma: Threaded decoder: Support zpipe.c-style decoding loop.
Lasse Collin [Sat, 2 Apr 2022 18:49:59 +0000 (21:49 +0300)] 
liblzma: Threaded decoder: Support zpipe.c-style decoding loop.

This makes it possible to call lzma_code() in a loop that only
reads new input when lzma_code() didn't fill the output buffer
completely. That isn't the calling style suggested by the
liblzma example program 02_decompress.c so perhaps the usefulness
of this feature is limited.

Also, it is possible to write such a loop so that it works
with the single-threaded decoder but not with the threaded
decoder even after this commit, or so that it works only if
lzma_mt.timeout = 0.

The zlib tutorial <https://zlib.net/zlib_how.html> is a well-known
example of a loop where more input is read only when output isn't
full. Porting this as is to liblzma would work with the
single-threaded decoder (if LZMA_CONCATENATED isn't used) but it
wouldn't work with threaded decoder even after this commit because
the loop assumes that no more output is possible when it cannot
read more input ("if (strm.avail_in == 0) break;"). This cannot
be fixed at liblzma side; the loop has to be modified at least
a little.

I'm adding this in any case because the actual code is simple
and short and should have no harmful side-effects in other
situations.

3 years agoUpdate THANKS.
Lasse Collin [Wed, 30 Mar 2022 21:05:07 +0000 (00:05 +0300)] 
Update THANKS.

3 years agoxzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).
Lasse Collin [Tue, 29 Mar 2022 16:19:12 +0000 (19:19 +0300)] 
xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).

Malicious filenames can make xzgrep to write to arbitrary files
or (with a GNU sed extension) lead to arbitrary code execution.

xzgrep from XZ Utils versions up to and including 5.2.5 are
affected. 5.3.1alpha and 5.3.2alpha are affected as well.
This patch works for all of them.

This bug was inherited from gzip's zgrep. gzip 1.12 includes
a fix for zgrep.

The issue with the old sed script is that with multiple newlines,
the N-command will read the second line of input, then the
s-commands will be skipped because it's not the end of the
file yet, then a new sed cycle starts and the pattern space
is printed and emptied. So only the last line or two get escaped.

One way to fix this would be to read all lines into the pattern
space first. However, the included fix is even simpler: All lines
except the last line get a backslash appended at the end. To ensure
that shell command substitution doesn't eat a possible trailing
newline, a colon is appended to the filename before escaping.
The colon is later used to separate the filename from the grep
output so it is fine to add it here instead of a few lines later.

The old code also wasn't POSIX compliant as it used \n in the
replacement section of the s-command. Using \<newline> is the
POSIX compatible method.

LC_ALL=C was added to the two critical sed commands. POSIX sed
manual recommends it when using sed to manipulate pathnames
because in other locales invalid multibyte sequences might
cause issues with some sed implementations. In case of GNU sed,
these particular sed scripts wouldn't have such problems but some
other scripts could have, see:

    info '(sed)Locale Considerations'

This vulnerability was discovered by:
cleemy desu wayo working with Trend Micro Zero Day Initiative

Thanks to Jim Meyering and Paul Eggert discussing the different
ways to fix this and for coordinating the patch release schedule
with gzip.

3 years agoliblzma: Fix a deadlock in threaded decoder.
Lasse Collin [Fri, 25 Mar 2022 23:02:44 +0000 (01:02 +0200)] 
liblzma: Fix a deadlock in threaded decoder.

If a worker thread has consumed all input so far and it's
waiting on thr->cond and then the main thread enables
partial update for that thread, the code used to deadlock.
This commit allows one dummy decoding pass to occur in this
situation which then also does the partial update.

As part of the fix, this moves thr->progress_* updates to
avoid the second thr->mutex locking.

Thanks to Jia Tan for finding, debugging, and reporting the bug.

3 years agoUpdate THANKS.
Lasse Collin [Wed, 23 Mar 2022 14:34:00 +0000 (16:34 +0200)] 
Update THANKS.

3 years agoliblzma: Threaded decoder: Don't stop threads on LZMA_TIMED_OUT.
Lasse Collin [Wed, 23 Mar 2022 14:28:55 +0000 (16:28 +0200)] 
liblzma: Threaded decoder: Don't stop threads on LZMA_TIMED_OUT.

LZMA_TIMED_OUT is not an error and thus stopping threads on
LZMA_TIMED_OUT breaks the decoder badly.

Thanks to Jia Tan for finding the bug and for the patch.

3 years agoxz: Add initial support for threaded decompression.
Lasse Collin [Sun, 6 Mar 2022 22:36:16 +0000 (00:36 +0200)] 
xz: Add initial support for threaded decompression.

If threading support is enabled at build time, this will
use lzma_stream_decoder_mt() even for single-threaded mode.
With memlimit_threading=0 the behavior should be identical.

This needs some work like adding --memlimit-threading=LIMIT.

The original patch from Sebastian Andrzej Siewior included
a method to get currently available RAM on Linux. It might
be one way to go but as it is Linux-only, the available-RAM
approach needs work for portability or using a fallback method
on other OSes.

The man page wasn't updated yet.

3 years agoliblzma: Add threaded .xz decompressor.
Lasse Collin [Sun, 6 Mar 2022 21:36:20 +0000 (23:36 +0200)] 
liblzma: Add threaded .xz decompressor.

I realize that this is about a decade late.

Big thanks to Sebastian Andrzej Siewior for the original patch.
I made a bunch of smaller changes but after a while quite a few
things got rewritten. So any bugs in the commit were created by me.

3 years agoliblzma: Fix docs: lzma_block_decoder() cannot return LZMA_UNSUPPORTED_CHECK.
Lasse Collin [Sun, 6 Mar 2022 14:54:23 +0000 (16:54 +0200)] 
liblzma: Fix docs: lzma_block_decoder() cannot return LZMA_UNSUPPORTED_CHECK.

If Check is unsupported, it will be silently ignored.
It's the caller's job to handle it.

3 years agoliblzma: Add new output queue (lzma_outq) features.
Lasse Collin [Sun, 6 Mar 2022 14:41:19 +0000 (16:41 +0200)] 
liblzma: Add new output queue (lzma_outq) features.

Add lzma_outq_clear_cache2() which may leave one buffer allocated
in the cache.

Add lzma_outq_outbuf_memusage() to get the memory needed for
a single lzma_outbuf. This is now used internally in outqueue.c too.

Track both the total amount of memory allocated and the amount of
memory that is in active use (not in cache).

In lzma_outbuf, allow storing the current input position that
matches the current output position. This way the main thread
can notice when no more output is possible without first providing
more input.

Allow specifying return code for lzma_outq_read() in a finished
lzma_outbuf.

3 years agoliblzma: Index hash: Change return value type of hash_append() to void.
Lasse Collin [Sun, 6 Mar 2022 13:18:58 +0000 (15:18 +0200)] 
liblzma: Index hash: Change return value type of hash_append() to void.

3 years agoliblzma: Minor addition to lzma_vli_size() API doc.
Lasse Collin [Tue, 22 Feb 2022 01:42:57 +0000 (03:42 +0200)] 
liblzma: Minor addition to lzma_vli_size() API doc.

Thanks to Jia Tan.

3 years agoliblzma: Check the return value of lzma_index_append() in threaded encoder.
Lasse Collin [Tue, 22 Feb 2022 00:04:18 +0000 (02:04 +0200)] 
liblzma: Check the return value of lzma_index_append() in threaded encoder.

If lzma_index_append() failed (most likely memory allocation failure)
it could have gone unnoticed and the resulting .xz file would have
an incorrect Index. Decompressing such a file would produce the
correct uncompressed data but then an error would occur when
verifying the Index field.

3 years agoUpdate THANKS.
Lasse Collin [Mon, 21 Feb 2022 23:37:39 +0000 (01:37 +0200)] 
Update THANKS.

3 years agoliblzma: Use non-executable stack on FreeBSD as on Linux
Ed Maste [Fri, 11 Feb 2022 15:25:46 +0000 (15:25 +0000)] 
liblzma: Use non-executable stack on FreeBSD as on Linux

3 years agoliblzma: Make Block decoder catch certain types of errors better.
Lasse Collin [Sun, 20 Feb 2022 18:36:27 +0000 (20:36 +0200)] 
liblzma: Make Block decoder catch certain types of errors better.

Now it limits the input and output buffer sizes that are
passed to a raw decoder. This way there's no need to check
if the sizes can grow too big or overflow when updating
Compressed Size and Uncompressed Size counts. This also means
that a corrupt file cannot cause the raw decoder to process
useless extra input or output that would exceed the size info
in Block Header (and thus cause LZMA_DATA_ERROR anyway).

More importantly, now the size information is verified more
carefully in case raw decoder returns LZMA_OK. This doesn't
really matter with the current single-threaded .xz decoder
as the errors would be detected slightly later anyway. But
this helps avoiding corner cases in the upcoming threaded
decompressor, and it might help other Block decoder uses
outside liblzma too.

The test files bad-1-lzma2-{9,10,11}.xz test these conditions.
With the single-threaded .xz decoder the only difference is
that LZMA_DATA_ERROR is detected in a difference place now.

3 years agoTests: Add bad-1-lzma2-11.xz.
Lasse Collin [Sun, 20 Feb 2022 17:38:55 +0000 (19:38 +0200)] 
Tests: Add bad-1-lzma2-11.xz.

3 years agoTranslations: Fix po4a failure with the French man page translations.
Lasse Collin [Fri, 18 Feb 2022 16:51:10 +0000 (18:51 +0200)] 
Translations: Fix po4a failure with the French man page translations.

Thanks to Mario Blättermann for the patch.

3 years agoTranslations: Add French translation of man pages.
Lasse Collin [Sun, 6 Feb 2022 23:14:37 +0000 (01:14 +0200)] 
Translations: Add French translation of man pages.

This matches xz-utils 5.2.5-2 in Debian.

The translation was done by "bubu", proofread by the debian-l10n-french
mailing list contributors, and submitted to me on the xz-devel mailing
list by Jean-Pierre Giraud. Thanks to everyone!