]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
3 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.

3 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.

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

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

3 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.

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

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

3 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.

3 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.

3 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.

3 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.

3 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.

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

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

3 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.

3 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.

3 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.

3 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.

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

3 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.

3 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.

3 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.

3 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.

3 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.

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.

4 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.

4 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.

4 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.

4 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.

4 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.

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

4 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

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

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

4 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.

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

4 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.

4 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.

4 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.