1
0
mirror of https://git.tukaani.org/xz.git synced 2025-03-02 14:40:40 +00:00

2597 Commits

Author SHA1 Message Date
Lasse Collin
3ed40b9f87
Windows: Revert the setlocale(LC_ALL, ".UTF8") documentation
Only leave the FindFileFirstA() notes from 20dfca81, reverting
the incorrect setlocale() notes. On Windows, Gettext's <libintl.h>
overrides setlocale() with libintl_setlocale() wrapper. I hadn't
noticed this, and thus my conclusions were wrong.

Fixes: 20dfca8171dad4c64785ac61d5b68972c444877b
(cherry picked from commit e607329a615759f1519016595dd38df7c89208f2)
2024-12-20 16:35:12 +02:00
Lasse Collin
4e0ebbabe4
tuklib_mbstr_width: Change the behavior when wcwidth() is not available
If wcwidth() isn't available (Windows), previously it was assumed
that one byte == one column in the terminal. Now it is assumed that
one multibyte character == one column. This works better with UTF-8.
Languages that only use single-width characters without any combining
characters should work correctly with this.

In xz, none of po/*.po contain combining characters and only ko.po,
zh_CN.po, and zh_TW.po contain fullwidth characters. Thus, "only"
those three translations in xz are broken on Windows with the
UTF-8 code page. Broken means that column headings in xz -lvv and
(only in the master branch) strings in --long-help are misaligned,
so it's not a huge problem. I don't know if those three languages
displayed perfectly before the UTF-8 change because I hadn't tested
translations with native Windows builds before.

Fixes: 46ee0061629fb075d61d83839e14dd193337af59
(cherry picked from commit b797c44c42ea54fe1c52722a2fca0c9618575598)
2024-12-18 19:22:01 +02:00
Lasse Collin
4ff609adb0
xzdec: Use setlocale() via tuklib_gettext_setlocale()
xzdec isn't translated and didn't have locale-specific behavior
in the past. On Windows with UTF-8 in the application manifest,
setting the locale makes a difference though:

  - Without any setlocale() call, non-ASCII filenames don't display
    properly in Command Prompt unless one first uses "chcp 65001"
    to set the console code page to UTF-8.

  - setlocale(LC_ALL, "") is enough to make non-ASCII filenames
    print correctly in Command Prompt without using "chcp 65001",
    assuming that the non-UTF-8 code page (like 850) supports
    those non-ASCII characters.

  - setlocale(LC_ALL, ".UTF8") is even better because then mbrtowc() and
    such functions use an UTF-8 locale instead of a legacy code page.
    The tuklib_gettext_setlocale() macro takes care of this (without
    enabling any translations).

Fixes: 46ee0061629fb075d61d83839e14dd193337af59
(cherry picked from commit 78868b6ed63fa4c89f73e3dfed27abfb8b0d46db)
2024-12-18 19:22:00 +02:00
Lasse Collin
4e7a48bf15
Windows: Use UTF-8 locale when active code page is UTF-8
XZ Utils 5.6.3 set the active code page to UTF-8 to fix CVE-2024-47611.
This wasn't paired with UCRT-specific setlocale(LC_ALL, ".UTF8"), thus
non-ASCII characters from translations became mojibake.

Fixes: 46ee0061629fb075d61d83839e14dd193337af59
(cherry picked from commit 0d0b574cc45045d6150d397776340c068df59e2a)
2024-12-18 19:22:00 +02:00
Lasse Collin
d20e4115e1
Windows: Document the need for setlocale(LC_ALL, ".UTF8")
Also warn about unpaired surrogates and (somewhat UTF-8-specific)
MAX_PATH issue in FindFirstFileA().

Fixes: 46ee0061629fb075d61d83839e14dd193337af59
(cherry picked from commit 20dfca8171dad4c64785ac61d5b68972c444877b)
2024-12-18 19:22:00 +02:00
Lasse Collin
f9f0cdae8a
xzdec: Call tuklib_progname_init() early enough
If the early pledge() call on OpenBSD fails, it calls my_errorf()
which requires the "progname" variable.

Fixes: d74fb5f060b76db709b50f5fd37490394e52f975
(cherry picked from commit 4e936f234056e5831013ed922145b666b04bb1e3)
2024-12-18 19:22:00 +02:00
Lasse Collin
3e0bc4e91f
CMake: Bump maximum policy version to 3.31
With CMake 3.31, there were a few warnings from
CMP0177 "install() DESTINATION paths are normalized".
These occurred because the install(FILES) command in
my_install_man_lang() is called with a DESTINATION path
that contains two consecutive slashes, for example,
"share/man//man1". Such a path is for the English man pages.
With translated man pages, the language code goes between
the slashes. The warning was probably triggered because the
extra slash gets removed by the normalization.

(cherry picked from commit 61feaf681bd793dc5c919732b44bca7dcf2ed1b8)
2024-12-18 19:22:00 +02:00
Lasse Collin
55127b25f2
Update THANKS
(cherry picked from commit b0bb84dd7bbdcc85243386a0051c7b2cb5fc6a18)
2024-12-18 19:22:00 +02:00
Dexter Castor Döpping
d86fa15b72
liblzma: Fix incorrect macro name in a comment
Fixes: 33b8a24b6646a9dbfd8358405aec466b13078559
Closes: https://github.com/tukaani-project/xz/pull/155
(cherry picked from commit bee0c044d30a6ad3b3d94901c27e7519f6f46e27)
2024-12-18 19:22:00 +02:00
Lasse Collin
86e8b03d20
Translations: Update the Chinese (traditional) translation
(cherry picked from commit b36177273602ebc83e9cc58517f63a7b6af33f70)
2024-12-18 19:21:59 +02:00
Lasse Collin
9c5bab8bd1
Update THANKS
(cherry picked from commit 9f69e71e78621fd056f5eaaad7cdcd9279310fb5)
2024-12-18 19:21:59 +02:00
Mark Wielaard
d9c2e7572b
xz: Landlock: Fix a file descriptor leak
(cherry picked from commit 48ff3f06521ca326996ab9a04d1b342098960427)
2024-12-18 19:21:59 +02:00
Sam James
77cab41f32
CI: update FreeBSD, NetBSD, OpenBSD, Solaris actions
Checked the changes and they're all innocuous. This should hopefully
fix the "externally managed" pip error in these jobs that started
recently.

(cherry picked from commit dbca3d078ec581600600abebbb18769d3d713914)
2024-12-18 19:21:59 +02:00
Lasse Collin
6084b25c29
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: 597f49b61475438a43a417236989b2acc968a686
(cherry picked from commit be4bf94446b6286a5dffdde85fc1d21448f4edff)
2024-10-01 19:14:30 +03:00
Lasse Collin
9331ce4009
Bump version and soname for 5.6.3 v5.6.3 2024-10-01 12:50:28 +03:00
Lasse Collin
f52857ffde
Add NEWS for 5.6.3 2024-10-01 12:50:22 +03:00
Lasse Collin
b8f52990b5
Update THANKS
(cherry picked from commit 1ebbe915d4e0d877154261b5f8103719a6722975)
2024-10-01 12:16:29 +03:00
Lasse Collin
51f6f45587
Tests/Windows: Add the application manifest to the test programs
This ensures that the test programs get executed the same way as
the binaries that are installed.

(cherry picked from commit 74702ee00ecfd080d8ab11118cd25dbe6c437ec0)
2024-10-01 12:16:29 +03:00
Lasse Collin
bf518b9ba4
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.
    See the new file w32_application.manifest.comments.txt.

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 46ee0061629fb075d61d83839e14dd193337af59)
2024-10-01 12:16:29 +03:00
Lasse Collin
5718ce932e
Windows: Set DLL name accurately in StringFileInfo on Cygwin and MSYS2
Now the information in the "Details" tab in the file properties
dialog matches the naming convention of Cygwin and MSYS2. This
is only a cosmetic change.

(cherry picked from commit dad153091552b52a41b95ec4981c6951f1cae487)
2024-10-01 12:16:28 +03:00
Lasse Collin
e77c0ca61d
common_w32res.rc: White space edits
LANGUAGE and VS_VERSION_INFO begin new statements so put an empty line
between them.

(cherry picked from commit 8940ecb96fe9f0f2a9cfb8b66fe9ed31ffbea904)
2024-10-01 12:16:28 +03:00
Lasse Collin
e0ba0f26d9
CMake: Add the resource files to the Cygwin and MSYS2 builds
Autotools-based build has always done this so this is for consistency.

However, the CMake build won't create the DEF file when building
for Cygwin or MSYS2 because in that context it should be useless.
(If Cygwin or MSYS2 is used to host building of normal Windows
binaries then the DEF file is still created.)

(cherry picked from commit c3b9dad07d3fd9319f88386b7095019bcea45ce1)
2024-10-01 12:16:28 +03:00
Lasse Collin
69637d0c32
CMake: Fix Windows resource file dependencies
If common_w32res.rc is modified, the resource files need to be rebuilt.
In contrast, the liblzma*.map files truly are link dependencies.

(cherry picked from commit da4f275bd1c18b897e5c2dd0043546de3accce0a)
2024-10-01 12:16:28 +03:00
Lasse Collin
af8533459c
CMake: Checking for CYGWIN covers MSYS2 too
On MSYS2, both CYGWIN and MSYS are set.

(cherry picked from commit 1c673c0aac7f7dee8dda2c1140351c8417a71e47)
2024-10-01 12:16:28 +03:00
Lasse Collin
eca08e4c20
Translations: Add the SPDX license identifier to pt_BR.po
(cherry picked from commit 6aaa0173b839e28429d43a8b62d257ad2f3b4521)
2024-10-01 12:16:12 +03:00
Lasse Collin
85801c96c3
Windows/CMake: Use the correct resource file for lzmadec.exe
CMakeLists.txt was using xzdec_w32res.rc for both xzdec and lzmadec.

Fixes: 998d0b29536094a89cf385a3b894e157db1ccefe
(cherry picked from commit dc7b9f24b737e4e55bcbbdde6754883f991c2cfb)
2024-09-25 21:33:12 +03:00
Lasse Collin
a341d19c83
Translations: Update the Brazilian Portuguese translation
(cherry picked from commit b834ae5f80911a3819d6cdb484f61b257174c544)
2024-09-25 21:33:12 +03:00
Lasse Collin
e69c0b9b2e
Update THANKS
(cherry picked from commit eceb023d4c129fd63ee881a2d8696eaf52ad1532)
2024-09-18 20:53:11 +03:00
Tobias Stoeckmann
aef9a25b32
lzmainfo: Avoid integer overflow
The MB output can overflow with huge numbers. Most likely these are
invalid .lzma files anyway, but let's avoid garbage output.

lzmadec was adapted from LZMA Utils. The original code with this bug
was written in 2005, over 19 years ago.

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
Closes: https://github.com/tukaani-project/xz/pull/144
(cherry picked from commit 76cfd0a9bb33ae8e534b1f73f6359dc825589f2f)
2024-09-18 20:53:11 +03:00
Tobias Stoeckmann
40a7f163f5
xzdec: Remove unused short option -M
"xzdec -M123" exited with exit status 1 without printing
any messages. The "M:" entry should have been removed when
the memory usage limiter support was removed from xzdec.

Fixes: 792331bdee706aa852a78b171040ebf814c6f3ae
Closes: https://github.com/tukaani-project/xz/pull/143
[ Lasse: Commit message edits ]

(cherry picked from commit 78355aebb7fb654302e5e33692ba109909dacaff)
2024-09-18 20:53:11 +03:00
Lasse Collin
c98714a570
Update THANKS
(cherry picked from commit e5758db7bd75587a2499e0771907521a4aa86908)
2024-09-18 20:53:11 +03:00
Firas Khalil Khana
4ed4495178
Build: Fix a typo in autogen.sh
Fixes: e9be74f5b129fe8a5388d588e68b1b7f5168a310
Closes: https://github.com/tukaani-project/xz/pull/141
(cherry picked from commit 80ffa38f56657257ed4d90d76f6bd2f2bcb8163c)
2024-09-18 20:53:04 +03:00
Lasse Collin
3b83577a15
Translations: Update Chinese (simplified) translation
Differences to the zh_CN.po file from the Translation Project:

  - Two uses of \v were fixed.

  - Missing "OPTS" translation in --riscv[=OPTS] was copied from
    previous lines.

  - "make update-po" was run to remove line numbers from comments.

(cherry picked from commit 68c54e45d042add64a4cb44bfc87ca74d29b87e2)
2024-09-06 19:33:21 +03:00
Lasse Collin
06f4c7edda
Translations: Update the Catalan translation
Differences to the ca.po file from the Translation Project:

  - An overlong line translating --filters-help was wrapped.

  - "make update-po" was used to remove line numbers from the comments
    to match the changes in fccebe2b4fd513488fc920e4dac32562ed3c7637
    and 093490b58271e9424ce38a7b1b38bcf61b9c86c6. xz.pot in the TP
    is older than these commits.

(cherry picked from commit 2230692aa1bcebb586100183831e3daf1714d60a)
2024-09-06 19:33:21 +03:00
Lasse Collin
406cb5b669
Update THANKS
(cherry picked from commit 5e375987509fab484b7bef0b90be92f241c58c91)
2024-09-06 19:33:21 +03:00
Yifeng Li
3a4a05d75e
liblzma: Fix x86-64 movzw compatibility in range_decoder.h
Support for instruction "movzw" without suffix in "GNU as" was
added in commit [1] and stabilized in binutils 2.27, released
in August 2016. Earlier systems don't accept this instruction
without a suffix, making range_decoder.h's inline assembly
unable to build on old systems such as Ubuntu 16.04, creating
error messages like:

    lzma_decoder.c: Assembler messages:
    lzma_decoder.c:371: Error: no such instruction: `movzw 2(%r11),%esi'
    lzma_decoder.c:373: Error: no such instruction: `movzw 4(%r11),%edi'
    lzma_decoder.c:388: Error: no such instruction: `movzw 6(%r11),%edx'
    lzma_decoder.c:398: Error: no such instruction: `movzw (%r11,%r14,4),%esi'

Change "movzw" to "movzwl" for compatibility.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c07315e0c610e0e3317b4c02266f81793df253d2

Suggested-by: Lasse Collin <lasse.collin@tukaani.org>
Tested-by: Yifeng Li <tomli@tomli.me>
Signed-off-by: Yifeng Li <tomli@tomli.me>
Fixes: 3182a330c1512cc1f5c87b5c5a272578e60a5158
Fixes: https://github.com/tukaani-project/xz/issues/121
Closes: https://github.com/tukaani-project/xz/pull/136
(cherry picked from commit 6cd7c8607843c337edfe2c472aa316602a393754)
2024-09-06 19:33:20 +03:00
Lasse Collin
4669f06d1a
Build: Comment that elf_aux_info(3) will be available on OpenBSD >= 7.6
(cherry picked from commit bf901dee5d4c46609645e50311c0cb2dfdcf9738)
2024-09-06 19:33:20 +03:00
Lasse Collin
9edddda563
liblzma: Tweak a comment
(cherry picked from commit 7c292dd0bf23cefcdf4b1509f3666322e08a7ede)
2024-09-06 19:33:20 +03:00
Lasse Collin
1a93ab55d1
CMake: Bump maximum policy version to 3.30 2024-09-06 19:33:16 +03:00
Lasse Collin
cfe4465742
Update THANKS
(cherry picked from commit 028185dd4889e3d6235ff13560160ebca6985021)
2024-09-06 19:31:13 +03:00
Lasse Collin
0f47db18d0
xz: Remove the TODO comment about --recursive
It won't be implemented. find + xargs is more flexible, for example,
it allows compressing small files in parallel. An example for that
has been included in the xz man page since 2010.

(cherry picked from commit baecfa142644eb5f5c6dd6f8e2f531c362fa3747)
2024-09-06 19:31:12 +03:00
Lasse Collin
07f52c3528
CMake: Link xz against Threads::Threads if using pthreads
The liblzma target was recently changed to link against Threads::Threads
with the PRIVATE keyword. I had forgotten that xz itself depends on
pthreads too due to pthread_sigmask(). Thus, the build broke when
building shared liblzma and pthread_sigmask() wasn't in libc.

Thanks to Peter Seiderer for the bug report.

Fixes: ac05f1b0d7cda1e7ae79775a8dfecc54601d7f1c
Fixes: https://github.com/tukaani-project/xz/issues/129#issuecomment-2204522994
(cherry picked from commit b3e53122f42796aaebd767bab920cf7bedf69966)
2024-09-06 19:30:12 +03:00
Lasse Collin
eccb4d258b
Update THANKS
(cherry picked from commit 5742ec1fc7f2cf1c82cfe3477bb90594a4658374)
2024-09-06 19:28:52 +03:00
Sam James
c9bd00327f
CI: Speed up Valgrind job by using --trace-children-skip-by-arg=...
This addresses the issue I mentioned in
6c095a98fbec70b790253a663173ecdb669108c4 and speeds up the Valgrind
job a bit, because non-xz tools aren't run unnecessarily with
Valgrind by the script tests.

(cherry picked from commit 7e99856f66c07852c4e0de7aa01951e9147d86b0)
2024-09-06 19:26:09 +03:00
Lasse Collin
495de6ec9d
Build: Prepend, not append, PTHREAD_CFLAGS to LIBS
It shouldn't make any difference because LIBS should be empty
at that point in configure. But prepending is the correct way
because in general the libraries being added might require other
libraries that come later on the command line.

(cherry picked from commit 2402e8a1ae92676fa0d4cb1b761d7f62f005c098)
2024-09-06 19:26:01 +03:00
Lasse Collin
55bf3f49a8
Build: Use AC_LINK_IFELSE to handle implicit function declarations
It's more robust in case the compiler allows pre-C99 implicit function
declarations. If an x86 intrinsic is missing and gets treated as
implicit function, the linking step will very probably fail. This
isn't the only way to workaround implicit function declarations but
it might be the simplest and cleanest.

The problem hasn't been observed in the wild.

There are a couple more AC_COMPILE_IFELSE uses in configure.ac.
Of these, Landlock check calls prctl() and in theory could have
the same problem. In practice it doesn't as the check program
looks for several other things too. However, it was changed to
AC_LINK_IFELSE still to look more correct.

Similarly, m4/tuklib_cpucores.m4 and m4/tuklib_physmem.m4 were
updated although they haven't given any trouble either. They
have worked all these years because those check programs rely
on specific headers and types: if headers or types are missing,
compilation will fail. Using the linker makes these checks more
similar to the ones in cmake/tuklib_*.cmake which always link.

(cherry picked from commit 7bb46f2b7b3989c1b589a247a251470f65e91cda)
2024-09-06 19:25:52 +03:00
Lasse Collin
b45270d88f
Build: Use AC_LINK_IFELSE instead of -Werror
AC_COMPILE_IFELSE needed -Werror because Clang <= 14 would merely
warn about the unsupported attribute and implicit function declaration.
Changing to AC_LINK_IFELSE handles the implicit declaration because
the symbol __crc32d is unlikely to exist in libc.

Note that the other part of the check is that #include <arm_acle.h>
must work. If the header is missing, most compilers give an error
and the linking step won't be attempted.

Avoiding -Werror makes the check more robust in case CFLAGS contains
warning flags that break -Werror anyway (but this isn't the only check
in configure.ac that has this problem). Using AC_LINK_IFELSE also makes
the check more similar to how it is done in CMakeLists.txt.

(cherry picked from commit 35eb57355ad1c415a838d26192d5af84abb7cf39)
2024-09-06 19:25:52 +03:00
Lasse Collin
2c3e4cbbdc
Build: Sync the compile check changes from CMakeLists.txt
It's nice to keep these in sync. The use of main() will later allow
AC_LINK_IFELSE usage too which may avoid the more fragile -Werror.

(cherry picked from commit 5a728813c378cc3c4c9c95793762452418d08f1b)
2024-09-06 19:25:52 +03:00
Lasse Collin
809e69f1f5
CMake: Use configure_file() to copy a file
I had missed this simpler method before. It does create a dependency
so that if .in.h changes the copying is done again.

(cherry picked from commit de215a0517645d16343f3a5336d3df884a4f665f)
2024-09-06 19:25:19 +03:00
Lasse Collin
52a8c87f37
CMake: Always add pthread flags into CMAKE_REQUIRED_LIBRARIES
It was weird to add CMAKE_THREAD_LIBS_INIT in CMAKE_REQUIRED_LIBRARIES
only if CLOCK_MONOTONIC is available. Alternative would be to remove
the thread libs from CMAKE_REQUIRED_LIBRARIES after the check for
pthread_condattr_setclock() but keeping the libs should be fine too.
Then it's ready in case more pthread functions were wanted some day.

(cherry picked from commit e620f35097c0ad20cd76d8258750aa706758ced9)
2024-09-06 19:25:03 +03:00