Commit Graph

1522 Commits

Author SHA1 Message Date
Lasse Collin c0f4269966
cmake/tuklib_large_file_support.cmake: Add a missing include
v5.2 didn't build with CMake. Other branches had
include(CMakePushCheckState) in top-level CMakeLists.txt
which made the build work.

Fixes: 597f49b614
(cherry picked from commit be4bf94446)
2024-10-01 14:53:47 +03:00
Lasse Collin 9ecccb3d5f
Windows: Embed an application manifest in the EXE files
IMPORTANT: This includes a security fix to command line tool
           argument handling.

Some toolchains embed an application manifest by default to declare
UAC-compliance. Some also declare compatibility with Vista/8/8.1/10/11
to let the app access features newer than those of Vista.

We want all the above but also two more things:

  - Declare that the app is long path aware to support paths longer
    than 259 characters (this may also require a registry change).

  - Force the code page to UTF-8. This allows the command line tools
    to access files whose names contain characters that don't exist
    in the current legacy code page (except unpaired surrogates).
    The UTF-8 code page also fixes security issues in command line
    argument handling which can be exploited with malicious filenames.

Thanks to Orange Tsai and splitline from DEVCORE Research Team
for discovering this issue.

Thanks to Vijay Sarvepalli for reporting the issue to me.

Thanks to Kelvin Lee for testing with MSVC and helping with
the required build system fixes.

(cherry picked from commit 46ee006162)
2024-10-01 13:23:16 +03:00
Lasse Collin e17caec12e Bump version and soname for 5.2.13 2024-05-29 17:51:23 +03:00
Lasse Collin c38f850536 Add NEWS for 5.2.13 2024-05-29 17:49:42 +03:00
Lasse Collin a59aae8d28 Build: Update po/*.po files only when needed
When po/xz.pot doesn't exist, running "make" or "make dist" will
create it. Then the .po files will be updated but only if they
actually would change more than the POT-Creation-Date line.
Then the .gmo files would be generated from the .po files.
This is the case before and after this commit.

However, "make dist" and thus "make mydist" did a forced update
to the files, updating them even if the only change was the
POT-Creation-Date line. This had pros and cons: It made it clear
that the .po file really is in sync with the recent strings in
the package. On the other hand, it added noise in form of changed
files in the source tree and distribution tarballs. It can be
ignored with something like "diff -I'^"POT-Creation-Date: '" but
it's still a minor annoyance *if* there's not enough value in
having the most recent timestamp.

Setting DIST_DEPENDS_ON_UPDATE_PO = no means that such forced
update won't happen in "make dist" anymore. However, the "mydist"
target will use xz.pot-update target which is the same target that
is run when xz.pot doesn't exist at all yet. Thus "mydist" will
ensure that the translations are up to date, without noise from
changes that would affect only the POT-Creation-Date line.

Note that po4a always uses msgmerge with --update, so POT-Creation-Date
in the man page translations is never the only change in .po files.
In that sense this commit makes the message translations behave more
similarly to the man page translations.

Distribution tarballs will still have non-reproducible POT-Creation-Date
in po/xz.pot and po4a/xz-man.pot but those are just two files. Even they
could be made reproducible from a Git timestamp if desired.

(cherry picked from commit 9284f1aea3)
2024-05-29 17:49:27 +03:00
Lasse Collin ac0658fa6d Translations: Run po4a/update-po and cleanup unused strings
The v5.2 branch won't get any translation updates so the fuzzy
strings and obsolete strings are all useless. Cleaning them up
makes the files smaller and less messy to compare.

    ./update-po

    for I in *.po
    do
        msgattrib --clear-fuzzy --clear-previous --empty \
                  --no-obsolete --no-wrap "$I" > tmp
        mv tmp "$I"
    done

The po4a run gave "Parse error at" message from fr.po but
after the fr.po was rewritten the error is gone.
2024-05-28 21:23:47 +03:00
Lasse Collin 2bc80e5f82 po4a/update-po: Disable wrapping in .pot and .po files
The .po files from the Translation Project come with unwrapped
strings so this matches it.

This may reduce the noise in diffs too. When the beginning of
a paragraph had changed, the rest of the lines got rewrapped
in msgsid. Now it's just one very long line that changes when
a paragraph has been edited.

The --add-location=file option was removed as redundant. The line
numbers don't exist in the .pot file due to --porefs file and thus
they cannot get copied to the .po files either.

(cherry picked from commit 4beba1cd62)
2024-05-28 21:20:55 +03:00
Lasse Collin 27cfdc5897 Update contact info in README
(cherry picked from commit b14c130a58)
2024-05-28 18:42:45 +03:00
Lasse Collin 649b1ca6e5 Translations: Run "make -C po update-po"
In the past this wasn't done before releases; the Git repository
just contained the files from the Translation Project. But this
way it is clearer when comparing release tarballs against the
Git repository.
2024-05-28 18:42:45 +03:00
Lasse Collin af667d7f49 Translations: Use --package-name=xz-man with po4a
This is to match reality. See the added comment.

(cherry picked from commit 75f5f2e014)
2024-05-28 17:21:47 +03:00
Lasse Collin 6e49bd6c46 Translations: Omit man page line numbers from .pot and .po files
(cherry picked from commit 9114267038)
2024-05-28 17:21:47 +03:00
Lasse Collin fd38afb628 Translations: Update po/Makevars
Use the template from gettext 0.22.5.
Add --add-location=file to XGETTEXT_OPTIONS and MSGMERGE_OPTIONS.
Add --no-wrap to MSGINIT_OPTIONS.

(cherry picked from commit 451f6986a5)
2024-05-28 17:21:47 +03:00
Lasse Collin 31d3912f29 liblzma: Omit an unneeded array from the x86 filter
Fixes: 6aa2a6deeb
(cherry picked from commit de06b9f0c0)
2024-05-27 16:57:13 +03:00
Lasse Collin 891602da97 liblzma: Silence a warning from Coverity static analysis
It is logical why it cannot know for sure that the value has
to be at most 4 if it is less than 16.

The x86 filter is based on a very old LZMA SDK version. Newer
ones have quite a different implementation for the same filter.

Thanks to Sam James.

(cherry picked from commit 6aa2a6deeb)
2024-05-27 16:57:13 +03:00
Lasse Collin 702b9ed690 Fix typos
Thanks to xx on #tukaani.

(cherry picked from commit 4e9023857d)
2024-05-22 00:34:26 +03:00
Lasse Collin 37314d4d18 Update maintainer and author info.
The other maintainer suddenly disappeared.

(cherry picked from commit 77a294d98a)
(cherry picked from commit 37c46f7b67)
2024-05-22 00:34:26 +03:00
Lasse Collin 02d0318629 liblzma: Fix incorrect function type error from sanitizer
Clang 17 with -fsanitize=address,undefined:

    src/liblzma/common/filter_common.c:366:8: runtime error:
        call to function encoder_find through pointer to incorrect
        function type 'const lzma_filter_coder *(*)(unsigned long)'
    src/liblzma/common/filter_encoder.c:187: note:
        encoder_find defined here

Use a wrapper function to get the correct type neatly.
This reduces the number of casts needed too.

This issue could be a problem with control flow integrity (CFI)
methods that check the function type on indirect function calls.

Fixes: 3b34851de1
(cherry picked from commit 278563ef8f)
(cherry picked from commit 64e0a5f726)
2024-05-22 00:34:26 +03:00
Lasse Collin b933ef49a5 xz: Avoid arithmetic on a null pointer
It's undefined behavior. The result wasn't ever used as it occurred
in the last iteration of a loop.

Clang 17 with -fsanitize=address,undefined:

    $ src/xz/xz --block-list=123
    src/xz/args.c:164:12: runtime error: applying non-zero offset 1
        to null pointer

Fixes: 88ccf47205
Co-authored-by: Sam James <sam@gentoo.org>
(cherry picked from commit 77c8f60547)
(cherry picked from commit 203d482599)
2024-05-22 00:34:26 +03:00
Lasse Collin ecbc34d90b liblzma: index_decoder: Fix missing initializations on LZMA_PROG_ERROR
If the arguments to lzma_index_decoder() or lzma_index_buffer_decode()
were such that LZMA_PROG_ERROR was returned, the lzma_index **i
argument wasn't touched even though the API docs say that *i = NULL
is done if an error occurs. This obviously won't be done even now
if i == NULL but otherwise it is best to do it due to the wording
in the API docs.

In practice this matters very little: The problem can occur only
if the functions are called with invalid arguments, that is,
the calling application must already have a bug.

(cherry picked from commit 71eed2520e)
(cherry picked from commit 214569ace8)
2024-05-22 00:34:26 +03:00
Lasse Collin e0e53eb80f CMake: Bump maximum policy version to 3.29
(cherry picked from commit 80f72396ea)
2024-05-22 00:34:26 +03:00
Lasse Collin 46c574e70a xz man page: Use .ft CR instead of CW to silence warnings from groff.
(cherry picked from commit 31ef676567)
(cherry picked from commit 6edc2b554f)
2024-05-22 00:34:26 +03:00
Lasse Collin 33b2a5104a Update THANKS.
(cherry picked from commit db4dd74a34)
(cherry picked from commit 995afe4646)
2024-05-22 00:34:26 +03:00
Lasse Collin e60534b03b INSTALL: Document arguments of --enable-symbol-versions.
(cherry picked from commit 8a25ba024d)
(cherry picked from commit 44a5c1374e)
2024-05-22 00:34:26 +03:00
Lasse Collin be86d78acf Build: Use only the generic symbol versioning with NVIDIA HPC Compiler.
This does the previous commit with CMake.

AC_EGREP_CPP uses AC_REQUIRE so the outermost if-commands must
be changed to AS_IF to ensure that things wont break some day.
See 5a5bd7f871.

(cherry picked from commit 49324b711f)
(cherry picked from commit b03139b1d2)
2024-05-22 00:34:26 +03:00
Lasse Collin 0f455c2687 CMake: Use only the generic symbol versioning with NVIDIA HPC Compiler.
It doesn't support the __symver__ attribute or __asm__(".symver ...").
The generic symbol versioning can still be used since it only needs
linker support.

(cherry picked from commit c273123ed0)
(cherry picked from commit 08754772e8)
2024-05-22 00:34:26 +03:00
Lasse Collin 880556e98c Update THANKS.
(cherry picked from commit df7f487648)
(cherry picked from commit 9579efdbfd)
2024-05-22 00:34:26 +03:00
Lasse Collin 639d053823 liblzma: Minor comment edits.
(cherry picked from commit 3217b82b3e)
(cherry picked from commit 32e256c12a)
2024-05-22 00:34:26 +03:00
Sergey Kosukhin 7de966a02b liblzma: Fix building with NVHPC (NVIDIA HPC SDK).
NVHPC compiler has several issues that make it impossible to
build liblzma:
  - the compiler fails to produce valid code for delta_decode if the
    vectorization is enabled, which results in failed tests.

This introduces NVHPC-specific workarounds that address the issues.

(This commit was contributed under 0BSD but the author confirmed
that it is fine to backport it to the public domain branches. See
https://github.com/tukaani-project/xz/pull/90#issuecomment-2100185936
and the next two messages.)

(cherry picked from commit 096bc0e3f8)
(cherry picked from commit 65ac20807c)
2024-05-22 00:34:26 +03:00
Lasse Collin 13a0a0fc8f CMake: Disable symbol versioning on non-glibc Linux.
This better matches what configure.ac does. For example, musl has
only basic symbol versioning support:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Symbol_versioning

configure.ac tries to enable symbol versioning only with glibc
so now CMake does the same.

(cherry picked from commit 2ad7fad670)
(cherry picked from commit 78a015e753)
2024-05-22 00:34:26 +03:00
Lasse Collin 706134d965 CMake: Make symbol versioning configurable.
(cherry picked from commit 82f0c0d39e)
(cherry picked from commit 20e590bbed)
2024-05-22 00:34:26 +03:00
Lasse Collin a9b2d85120 CMake: Handle symbol versioning on MicroBlaze specially.
This is to match configure.ac.

(cherry picked from commit 025eb6d787)
(cherry picked from commit bcac3e3aa2)
2024-05-22 00:34:26 +03:00
Lasse Collin 93b928b230 Build: Style tweaks to configure.ac.
The AC_MSG_ERROR line is overlong anyway as are a few other
AC_MSG_ERROR lines already.

(cherry picked from commit 45d33bfc45)
(cherry picked from commit 9e7daa8dbd)
2024-05-22 00:34:26 +03:00
Sergey Kosukhin 2dbc0fc5c2 Build: Let the users override the symbol versioning variant.
There are cases when the users want to decide themselves whether
they want to have the generic (even on GNU/Linux) or the linux
(even if we do not recommend that) symbol versioning variant.
The former might be needed to circumvent compiler issues (i.e.
the compiler does not support all features that are required
for the linux versioning), the latter might help in overriding
the assumptions made in the configure script.

(This commit was contributed under 0BSD but the author confirmed
that it is fine to backport it to the public domain branches. See
https://github.com/tukaani-project/xz/pull/90#issuecomment-2100185936
and the next two messages.)

(cherry picked from commit f56ed6fac6)
(cherry picked from commit ce3a9fa94d)
2024-05-22 00:33:56 +03:00
Lasse Collin be29fac96d INSTALL: Clarify that --disable-assembler affects only 32-bit x86.
(cherry picked from commit 00440f52be)
(cherry picked from commit a8b3fb6d2f)
2024-05-22 00:28:10 +03:00
Lasse Collin 769b5d0055 xz: Delete old commented-out code.
(cherry picked from commit 4ce300ce08)
(cherry picked from commit b4b315a206)
2024-05-22 00:28:03 +03:00
Lasse Collin d800c85838 xz: Tweak comments.
(cherry picked from commit 7312dfbb02)
(cherry picked from commit 9c9a3e7b3f)
2024-05-22 00:27:48 +03:00
Lasse Collin 7d487a4c2a xz: Fix message_init() description.
Also explicitly initialize progress_automatic to make it clear
that it can be read before message_init() sets it. Static variable
was initialized to false by default already so this is only for
clarity.

(cherry picked from commit c701a5909a)
(cherry picked from commit 7d3418e496)
2024-05-22 00:27:25 +03:00
Lasse Collin 9c2d1b52ce Build: Don't install TODO.
(cherry picked from commit f3440e78c9)
(cherry picked from commit fb6cf07ac7)
2024-05-22 00:26:45 +03:00
Jia Tan 2c024f60c2 Update m4/.gitignore.
(cherry picked from commit 4323bc3e0c)
(cherry picked from commit e164211b09)
2024-05-22 00:26:06 +03:00
Lasse Collin fda91a5d77 liblzma: Fix compilation of price_tablegen.c.
It is built and run only manually so this didn't matter
unless one wanted to regenerate the price_table.c.

(cherry picked from commit 8e4ec79483)
(cherry picked from commit 65b5ee0716)
2024-05-07 19:57:27 +03:00
Lasse Collin 594b64742f liblzma: Sync the AUTHORS fix about SHA-256 to lzma.h.
(based on commit 23de53421e)

(cherry picked from commit f200c338f8)
2024-05-07 19:57:27 +03:00
Lasse Collin 6aba0e2a5e Fix SHA-256 authors.
The initial commit 5d018dc035
in 2007 had a comment in sha256.c that the code is based on
Crypto++ Library 5.5.1. In 2009 the Authors list in sha256.c
and the AUTHORS file was updated with information that the
code had come from Crypto++ but via 7-Zip. I know I had viewed
7-Zip's SHA-256 code but back then the C code has been identical
enough with Crypto++, so I don't why I thought the author info
would need that extra step via 7-Zip for this single file.

Another error is that I had mixed sha.* and shacal2.* files
when checking for author info in Crypto++. The shacal2.* files
aren't related to liblzma's sha256.c and thus Kevin Springle's
code in Crypto++ isn't either.

(cherry picked from commit 76946dc433)
(cherry picked from commit 402fb45c74)
2024-05-07 19:57:27 +03:00
Lasse Collin 2c89f377cd xzless: Use ||- in LESSOPEN with with "less" 451 and newer.
(cherry picked from commit 9860d418d2)
(cherry picked from commit e5ba545f16)
2024-05-07 19:57:27 +03:00
Lasse Collin 3af41a23c4 xzless: Use --show-preproc-errors with "less" 632 and newer.
This makes "less" show a warning if a decompression error occurred.

(cherry picked from commit fd0692b052)
(cherry picked from commit 5e7a8c0869)
2024-05-07 19:57:27 +03:00
Lasse Collin 74d36a57c5 liblzma: Set all values in lzma_lz_encoder to NULL after allocation.
This is unlikely to be a bug in an existing application since it relies
on calling lzma_filters_update() on an LZMA1 encoder in the first place.
For instance, it does not affect xz because lzma_filters_update() can
only be used when encoding to the .xz format.

(based on commit 8191720eac)
2024-05-07 19:56:46 +03:00
Jia Tan 176ae9073c liblzma: Make parameter names in function definition match declaration.
lzma_raw_encoder() and lzma_raw_encoder_init() used "options" as the
parameter name instead of "filters" (used by the declaration). "filters"
is more clear since the parameter represents the list of filters passed
to the raw encoder, each of which contains filter options.

(cherry picked from commit 27ab54af84)
2024-05-07 17:57:51 +03:00
Jia Tan 94c8503486 liblzma: Improve lzma encoder init function consistency.
lzma_encoder_init() did not check for NULL options, but
lzma2_encoder_init() did. This is more of a code style improvement than
anything else to help make lzma_encoder_init() and lzma2_encoder_init()
more similar.

(cherry picked from commit 019afd72e0)
2024-05-07 17:57:51 +03:00
Jia Tan fa91e29dba Docs: Update repository URL in Changelog.
(cherry picked from commit 6af9a4cbe5)
2024-05-07 17:57:51 +03:00
Jia Tan 6a7c0a9ab2 xz: Use is_tty() in message.c.
(cherry picked from commit 7dc466d621)
2024-05-07 17:57:51 +03:00
Jia Tan 9f00ad72f0 xz: Create separate is_tty() function.
The new is_tty() will report if a file descriptor is a terminal or not.
On POSIX systems, it is a wrapper around isatty(). However, the native
Windows implementation of isatty() will return true for all character
devices, not just terminals. So is_tty() has a special case for Windows
so it can use alternative Windows API functions to determine if a file
descriptor is a terminal.

This fixes a bug with MSVC and MinGW-w64 builds that refused to read from
or write to non-terminal character devices because xz thought it was a
terminal. For instance:

    xz foo -c > /dev/null

would fail because /dev/null was assumed to be a terminal.

(cherry picked from commit 0ecfaa6df9)
2024-05-07 17:57:49 +03:00