commit d24a57b7fc7e5e9267b84367cb0788d3acf7f569
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-30 16:41:03 +0300

    Bump version and soname for 5.2.7.

 src/liblzma/Makefile.am        | 2 +-
 src/liblzma/api/lzma/version.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

commit d2003362dd42004355a5550ee7a60ace3b3ea2d8
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-30 16:40:39 +0300

    Add NEWS for 5.2.7.

 NEWS | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

commit 369afb51991e91a5c3a23c4ae3872329a403eb31
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-30 12:06:13 +0300

    liblzma: Add API doc note about the .xz decoder LZMA_MEMLIMIT_ERROR bug.
    
    The bug was fixed in 660739f99ab211edec4071de98889fb32ed04e98.

 src/liblzma/api/lzma/base.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

commit 166431e9951613481b8136f52b570d7bc30b5a03
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-09-21 16:15:50 +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.

 src/liblzma/common/index.c | 3 +++
 1 file changed, 3 insertions(+)

commit 5e53a6c28b87a0bb9b0cfeaf708cc99ef8e9bc66
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-09-21 20:29:28 +0800

    Tests: Create a test for the lzma_index_cat bug.

 tests/test_index.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

commit 4ed5fd54c676b735e3f58158f214af68755d59b5
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-09-21 19:28:53 +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.

 src/liblzma/common/index.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

commit c4476f695291a2d7376d5fa406d32e354f858858
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-28 12:20:41 +0300

    tuklib_physmem: Fix Unicode builds on Windows.
    
    Thanks to ArSaCiA Game.

 src/common/tuklib_physmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 976f897bbba9890a99f01a8d59c6d59c230142e6
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-28 11:05:15 +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.

 src/liblzma/common/stream_decoder.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

commit 2caa9580e5f7c5cc6668e9427a2c21f3f63bb684
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-28 11:00:23 +0300

    liblzma: Stream decoder: Fix comments.

 src/liblzma/common/stream_decoder.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

commit 51882fec5b96cf7760389b670d86c1e7a5a0ced2
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-16 14:09:07 +0300

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit 974186f7cd839f1dbf937b98e112dff670d2bd5c
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-16 14:07:03 +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.

 src/scripts/xzgrep.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

commit f94da15120c3d3c363ca12c2262ac6cb9f321f4f
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-09 13:51:57 +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.

 src/liblzma/api/lzma/filter.h      |  4 +++-
 src/liblzma/common/filter_common.c | 18 ++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

commit ea57b9aa2c3e1cdb667f8dd698314b1c36047018
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-16 17:08:53 +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.

 tests/files/README                         |  10 ++++++++++
 tests/files/bad-3-index-uncomp-overflow.xz | Bin 0 -> 132 bytes
 tests/test_files.sh                        |   8 ++++++++
 3 files changed, 18 insertions(+)

commit 72e1645a439a999638a63ec9abb7210671ea5415
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-09-02 20:18:55 +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.

 src/liblzma/common/index.c | 4 ++++
 1 file changed, 4 insertions(+)

commit 20d82bc90781aa9d2373efe872d90ba64dc7dc62
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-08 15:11:08 +0300

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit 31d80c6b261b24220776dfaeb8a04f80f80e0a24
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-04 23:23:00 +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.

 configure.ac                                     |  23 ++++-
 src/liblzma/Makefile.am                          |  10 +-
 src/liblzma/common/block_buffer_encoder.c        |  18 ++++
 src/liblzma/common/common.c                      |  14 +++
 src/liblzma/common/common.h                      |  28 ++++++
 src/liblzma/common/hardware_cputhreads.c         |  12 +++
 src/liblzma/common/stream_encoder_mt.c           |  42 ++++++++
 src/liblzma/{liblzma.map => liblzma_generic.map} |   6 +-
 src/liblzma/liblzma_linux.map                    | 123 +++++++++++++++++++++++
 src/liblzma/validate_map.sh                      | 113 +++++++++++++++++++--
 10 files changed, 374 insertions(+), 15 deletions(-)

commit e7a7ac744eb0f890ef52388de838596ef566c73f
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-09-08 15:07:00 +0300

    CMake: Clarify a comment about Windows symlinks without file extension.

 CMakeLists.txt | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

commit a273a0cb77c6000e4da627b07f28c5af41f0908c
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-08 15:02:41 +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.

 CMakeLists.txt | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

commit 5875a45be0ab399e37acc31165725a9b5291f67e
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-31 16:42:04 +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.

 CMakeLists.txt | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

commit 3523b6ebb56c447f21736f01bfe91602741aa3e7
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-31 16:29:38 +0300

    CMake: Put xz man page install under if(UNIX) like is for xzdec.
    
    Thanks to Jia Tan.

 CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

commit 5af9e8759f748a11a408bfc5aef829df3811fc23
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-09-16 15:10:07 +0300

    Translations: Add Turkish translation.

 po/LINGUAS |   1 +
 po/tr.po   | 977 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 978 insertions(+)

commit f05a69685e9c7f7157d751abfbd2d8ea6e3bacc7
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-18 17:49:16 +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.

 Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

commit ad5ef6d3c30bb749113c51aa0bbe8bcb5e193fbe
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-18 17:38:05 +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.

 windows/vs2013/liblzma_dll.vcxproj | 6 ++++++
 windows/vs2017/liblzma_dll.vcxproj | 6 ++++++
 windows/vs2019/liblzma_dll.vcxproj | 6 ++++++
 3 files changed, 18 insertions(+)

commit 8dfed05bdaa4873833ba24279f02ad2db25effea
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-12 14:30:13 +0300

    Bump version and soname for 5.2.6.

 src/liblzma/Makefile.am        | 2 +-
 src/liblzma/api/lzma/version.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

commit 09b4af4e04def5777b06124200b64b0b941eea7f
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-12 14:29:28 +0300

    Add NEWS for 5.2.6.

 NEWS | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 226 insertions(+)

commit 692de534fae6c38f92416793addcf5f60ffe2bf6
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-08-12 14:28:41 +0300

    Add Jia Tan to AUTHORS.

 AUTHORS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 275de376a645f406be7c453bb68427aa9466cf83
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-25 19:11:05 +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.

 po4a/update-po | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 76a5a752b8467ff591dd028deb61e9bf2c274c7e
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-07-25 18:30:05 +0300

    liblzma: Refactor lzma_mf_is_supported() to use a switch-statement.

 src/liblzma/lz/lz_encoder.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

commit 749b86c2c18ab61a07f19ec8fefc67325da97397
Author: Jia Tan <jiat0218@gmail.com>
Date:   2022-07-25 18:20:01 +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.

 configure.ac | 4 ++++
 1 file changed, 4 insertions(+)

commit 63e3cdef805a4d9ea94c76c36cbabe4dc76abe36
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2021-01-11 23:41:16 +0200

    xz: Make --keep accept symlinks, hardlinks, and setuid/setgid/sticky.
    
    Previously this required using --force but that has other
    effects too which might be undesirable. Changing the behavior
    of --keep has a small risk of breaking existing scripts but
    since this is a fairly special corner case I expect the
    likehood of breakage to be low enough.
    
    I think the new behavior is more logical. The only reason for
    the old behavior was to be consistent with gzip and bzip2.
    
    Thanks to Vincent Lefevre and Sebastian Andrzej Siewior.

 src/xz/file_io.c |  9 +++++----
 src/xz/xz.1      | 16 +++++++++++++++-
 2 files changed, 20 insertions(+), 5 deletions(-)

commit 9055584be0ae47032b7fb3ba8531aa56b9ed572a
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-19 23:19:49 +0300

    xzgrep man page: Document exit statuses.

 src/scripts/xzgrep.1 | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

commit 57e1ccbb7ce30e5298ea7ec3934e462fa8d32237
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-19 23:13:24 +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.

 src/scripts/xzgrep.in | 72 +++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 19 deletions(-)

commit 6351ea1afb261ec9be95f808bcbe724e0da4ae09
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-19 00:10:55 +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.

 src/scripts/xzgrep.in | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

commit 2c1ff2ed6b9f17b3913866a15d776ebbbeb824d2
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-18 21:52:31 +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.

 src/scripts/xzgrep.in | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

commit 8b0be38a795fa1cdffdada64341a34209e630060
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-18 21:10:25 +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.

 src/scripts/xzgrep.in | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

commit 4a61867a874c60b31448d2d4f3c276efba85a243
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-18 19:18:48 +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.

 src/scripts/xzdiff.in | 6 +++---
 src/scripts/xzgrep.in | 4 ++--
 src/scripts/xzless.in | 4 ++--
 src/scripts/xzmore.in | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

commit 0e222bf7d79a9792025c5ffeaa66c8e14eb47615
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-17 21:36:25 +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.

 src/scripts/xzgrep.in | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

commit 62c1d2bc2da66e182c52bb1e3aa791f6d8a9e099
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-17 20:55:16 +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.

 src/scripts/xzgrep.in | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

commit 372a0d12c95fad5e5477b4f79646bf66d28e0c31
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-14 20:33:05 +0300

    Tests: Add the .lzma files to test_files.sh.

 tests/test_files.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

commit b8e3d0c45b62c81dfc6b350556d77cf2c7401edd
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-14 19:37:42 +0300

    Tests: Add .lzma test files.

 tests/files/README                                 |  63 ++++++++++++++++-----
 tests/files/bad-too_big_size-with_eopm.lzma        | Bin 0 -> 37 bytes
 tests/files/bad-too_small_size-without_eopm-1.lzma | Bin 0 -> 31 bytes
 tests/files/bad-too_small_size-without_eopm-2.lzma | Bin 0 -> 31 bytes
 tests/files/bad-too_small_size-without_eopm-3.lzma | Bin 0 -> 36 bytes
 tests/files/bad-unknown_size-without_eopm.lzma     | Bin 0 -> 31 bytes
 tests/files/good-known_size-with_eopm.lzma         | Bin 0 -> 37 bytes
 tests/files/good-known_size-without_eopm.lzma      | Bin 0 -> 31 bytes
 tests/files/good-unknown_size-with_eopm.lzma       | Bin 0 -> 37 bytes
 9 files changed, 50 insertions(+), 13 deletions(-)

commit e96bdf7189916bffec0dcc933cd809fac898587c
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-14 18:12:38 +0300

    liblzma: Rename a variable and improve a comment.

 src/liblzma/lzma/lzma_decoder.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

commit 2d54fdf58e80bb2b0852633838576fd1ae7961c5
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-13 22:24:41 +0300

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit ff54b557fe3b06b59a24e4028c1464c35dd5b142
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-07-13 22:24:07 +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.

 doc/lzma-file-format.txt           | 11 ++++-
 src/liblzma/common/alone_decoder.c |  2 +-
 src/liblzma/lz/lz_decoder.c        | 10 +++-
 src/liblzma/lz/lz_decoder.h        |  8 +--
 src/liblzma/lzma/lzma2_decoder.c   |  2 +-
 src/liblzma/lzma/lzma_decoder.c    | 99 +++++++++++++++++++++++++++-----------
 6 files changed, 94 insertions(+), 38 deletions(-)

commit bb795fe835cf2b3ae7ed68b155784fbfc14e2faf
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-06-14 17:20:49 +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.

 tests/files/README                    |   5 +++++
 tests/files/good-1-empty-bcj-lzma2.xz | Bin 0 -> 52 bytes
 2 files changed, 5 insertions(+)

commit dbd8b0bf45c10f991635f585a2ea59fb5ae28ff3
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-03-31 00:05:07 +0300

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit bb66a98ded39c40df202da17cb2055356dcd4168
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-03-29 19:19:12 +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.

 src/scripts/xzgrep.in | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

commit fa3af4e4c6a8f692785b87ba0f165f34d154ae0f
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-03-23 16:34:00 +0200

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit f12ce0f23a0496daebc77e8359309bf724ad5e8a
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-03-06 16:54:23 +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.

 src/liblzma/api/lzma/block.h | 3 ---
 1 file changed, 3 deletions(-)

commit 412566731111edc28f0b68bc966d01ab24d17082
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-03-06 15:18:58 +0200

    liblzma: Index hash: Change return value type of hash_append() to void.

 src/liblzma/common/index_hash.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

commit 7c3ce02df001701a26c2fa41b2dc8b530743f454
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-22 03:42:57 +0200

    liblzma: Minor addition to lzma_vli_size() API doc.
    
    Thanks to Jia Tan.

 src/liblzma/api/lzma/vli.h | 2 ++
 1 file changed, 2 insertions(+)

commit b8f667fe0c3e17fd2c559901d2aaf19b1dfd51f2
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-22 02:04:18 +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.

 src/liblzma/common/stream_encoder_mt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

commit 2356d53edd8f44ff8f411972ca62d63079ff59af
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-22 01:37:39 +0200

    Update THANKS.

 THANKS | 1 +
 1 file changed, 1 insertion(+)

commit 748ef0833821f1ea4ff5d57abc3cab1ae76266d3
Author: Ed Maste <emaste@FreeBSD.org>
Date:   2022-02-11 15:25:46 +0000

    liblzma: Use non-executable stack on FreeBSD as on Linux

 src/liblzma/check/crc32_x86.S | 4 ++--
 src/liblzma/check/crc64_x86.S | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

commit 068a6e3286c9ca7d67f13f4c78646c4f4a3c3c5b
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-20 20:36:27 +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.

 src/liblzma/common/block_decoder.c | 79 ++++++++++++++++++++++++++------------
 1 file changed, 54 insertions(+), 25 deletions(-)

commit 766df4f62c165ba96d60af8fadbada51349fd140
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-20 19:38:55 +0200

    Tests: Add bad-1-lzma2-11.xz.

 tests/files/README            |   5 +++++
 tests/files/bad-1-lzma2-11.xz | Bin 0 -> 64 bytes
 2 files changed, 5 insertions(+)

commit 12a6d6ce2a9850e32140e542decfd9c8a33c87fc
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-18 18:51:10 +0200

    Translations: Fix po4a failure with the French man page translations.
    
    Thanks to Mario Blättermann for the patch.

 po4a/fr_FR.po | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

commit 00e6aad836cf301e95575ea53790f5ab96fe8ed6
Author: Lasse Collin <lasse.collin@tukaani.org>
Date:   2022-02-07 01:14:37 +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!

 po4a/fr_FR.po  | 3541 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 po4a/po4a.conf |    2 +-
 2 files changed, 3542 insertions(+), 1 deletion(-)

commit e20ce2b12251a246c50fb5b7fa2204c11611b407
Author: jiat75 <jiat0218@gmail.com>
Date:   2022-01-28 20:47:55 +0800

    liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.
    
    Previously lzma_lzma_props_encode() and lzma_lzma2_props_encode()
    assumed that the options pointers must be non-NULL because the
    with these filters the API says it must never be NULL. It is
    good to do these checks anyway.

 src/liblzma/lzma/lzma2_encoder.c | 3 +++
 src/liblzma/lzma/lzma_encoder.c  | 3 +++
