1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 11:24:56 +00:00

3066 Commits

Author SHA1 Message Date
Lasse Collin
47c44e9008
Tests: test_index: Test the stricter Number of Records condition 2026-07-20 21:16:17 +03:00
Lasse Collin
a9c92328bd
Tests: Add test file bad-0-index-1.xz 2026-07-20 21:16:17 +03:00
Lasse Collin
006126aca9
Revert "liblzma: Add internal constant INDEX_RECORDS_MAX"
This reverts commit 9ff4dadca96a5ac3cb478759a4fdb8663be114eb.
The INDEX_RECORDS_MAX constant isn't needed after the previous commit.
2026-07-20 21:16:17 +03:00
Lasse Collin
5005914f1a
liblzma: Index decoder: Reject an obviously-bad Number of Records better
File info decoder knows Backward Size, so pass it to the Index decoder.
Now the Index decoder, when called from the file info decoder, won't
allocate a large amount of memory when Backward Size is tiny and the
Number of Records field contains a huge invalid value.

If a reasonable memory usage limit was set, the old code returned
LZMA_MEMLIMIT_ERROR if the value in Number of Records was too huge.
Now it results in LZMA_DATA_ERROR which is better.
2026-07-20 21:16:17 +03:00
Lasse Collin
10dfae83fd
Tests: test_index: Add a test for the Index decoder memusage bug 2026-07-20 21:16:17 +03:00
Lasse Collin
bd3bfe8346
liblzma: Index decoder: Fix lzma_memusage()
If lzma_stream was initialized using lzma_index_decoder() or
lzma_file_info_decoder(), and lzma_memusage() was called after a few
Records had already been decoded, the return value was too low because
it was calculated based on the number of Records that haven't been
decoded yet. So near the end of a big Index, the return value would be
tiny compared to the actual memory usage.

It worked correctly in the primary use case, that is, after
LZMA_MEMLIMIT_ERROR. Thus, in practice this bug didn't matter much.
2026-07-20 21:16:17 +03:00
Lasse Collin
2187b27c64
Tests: test_index: Fix testing of _locate() with concatenated lzma_index 2026-07-20 21:16:11 +03:00
Lasse Collin
8d13dd61ec
Translations: Update the Brazilian Portuguese translation 2026-07-19 10:45:31 +03:00
Lasse Collin
791ce1bb6d
liblzma: Remove an outdated API doc in hardware.h 2026-07-19 10:40:44 +03:00
Lasse Collin
f3b5688159
Tests: Comment that a sanitizer may be needed for lzma_index_append() bug
Fixes: a3ea8832bec1 ("Tests: Add a test for the lzma_index_prealloc() + lzma_index_append() bug")
Link: https://github.com/tukaani-project/xz/issues/233
2026-07-03 16:55:03 +03:00
Lasse Collin
6a07932a87
Translations: Update the Croatian translation 2026-07-02 21:56:33 +03:00
Lasse Collin
b8d0707ae7
NEWS: Clarify which bug is CVE-2026-34743
Fixes: https://salsa.debian.org/debian/xz-utils/-/merge_requests/5#note_775071
2026-07-02 21:09:36 +03:00
Lasse Collin
e95cd90da9
Translations: Fix LTR/RTL issue in Arabic xz man page tables
The headings are RTL but in some tables the rows were LTR because the
first strong char was LTR, like the "e" in "-0e". Add {RLM}{LRM}...{RLM}
to those columns ("-0" to "-9", and "-0e" to "-9e"):

    sed -ri $'/^msgstr /{s/"(-[0-9]e?)"/"\u200f\u200e\\1\u200f"/}' ar.po

It's not perfect because groff doesn't treat RLM and LRM as zero-width
chars, and thus the columns are slightly misaligned. It's good enough
in practice still.

Thanks-to: Zayed Al-Saidi <zayed.alsaidi@gmail.com>
2026-06-21 20:53:49 +03:00
Lasse Collin
b46944d734
CI: Add 'timeout: 10' to coverity.yml 2026-06-21 20:53:49 +03:00
Lasse Collin
0def412006
CI: Don't pin vmactions or MSYS2 actions to commit ID
These workflows don't use any secrets other than GITHUB_TOKEN, which
only has the 'contents: read' permission. That is, if an action was
compromised, it shouldn't be able to modify the repository or steal any
secrets. I recognize that a compromised action isn't completely harmless
still. For example, the runners on GitHub have Internet access which the
action could abuse until the workflow timeout (currently 10 or 20 minutes)
expires.

Now we always use the most recent actions instead of ones that are
sometimes several months old. The hassle of updating the pinned
commit IDs goes away. The benefits feel bigger than the risks.

Link: https://github.com/tukaani-project/xz/pull/227
2026-06-21 20:53:49 +03:00
Lasse Collin
3c0dbed890
CI: Upgrade actions/checkout from v6 to v7 2026-06-21 20:53:49 +03:00
Lasse Collin
0fab61de63
CI: Run CI workflows on push to 'ci_run' in addition to 'master'
Make it convenient to run the CI workflows by pushing to a branch with
a specific name.
2026-06-21 20:53:49 +03:00
Lasse Collin
8e8c6598a5
CI: Remove the on 'pull_request:' entries
I don't run CI from PRs, so these just add noise to the "Actions" tab
in the GH UI.
2026-06-21 20:53:49 +03:00
Lasse Collin
88ae12f787
CI: Use 'contents: read' after all
If someone makes a private fork, then it will work there too.

Thanks-to: Eli Schwartz
2026-06-21 20:53:43 +03:00
Lasse Collin
b70af4d532
CI: Add 'permissions' to coverity.yml
GitHub's actions/checkout@v6 is documented to need 'contents: read' but
it works without it too, probably because the repository is public.

Reported-by: GitHub user Alb3e3
Fixes: https://github.com/tukaani-project/xz/pull/230
2026-06-17 22:15:10 +03:00
Lasse Collin
56c18ccfb7
liblzma: file info decoder: Add an integer overflow check
After the previous commit, the overflow should be impossible, but it's
better to add the check anyway.

Fixes: https://github.com/tukaani-project/xz/pull/226
2026-06-17 22:15:09 +03:00
Lasse Collin
a73f4c6715
liblzma: Index decoder: Reject an obviously-bad Number of Records early
There no point to try decoding further when the Index is clearly not
from a valid .xz file.

This also limits what index_decoder_memconfig() can return as the
memory usage. Very huge values aren't possible anymore. This affects
file_info_decoder_memconfig() in file_info.c where very huge values
aren't expected and could result in an integer overflow when not much
memory has actually been allocated. Now the overflow can only happen if
one manages to successfully allocate and fill a few exabytes of memory.

Reported-by: GitHub user jmestwa-coder
Fixes: https://github.com/tukaani-project/xz/pull/226
2026-06-17 22:15:09 +03:00
Lasse Collin
9ff4dadca9
liblzma: Add internal constant INDEX_RECORDS_MAX
It's the theoretical maximum number of Records that fit in a .xz file.
This can be used to reject obviously wrong values.
2026-06-17 22:15:09 +03:00
Lasse Collin
25a53ed6d1
Translation: Update Arabic man page translations
In two tables, the column headings are now narrower and

    MANWIDTH=80 man --warnings po4a/man/ar/xz.1 > /dev/null

no longer warns.

Thanks-to: Zayed Al-Saidi <zayed.alsaidi@gmail.com>
Fixes: https://github.com/tukaani-project/xz/pull/220
2026-06-17 22:15:04 +03:00
Lasse Collin
225c46e99c
xzdiff: Use LC_ALL=C with sed and expr
This is required to handle strings that may contain invalid multibyte
sequences. For example, on GNU/Linux and FreeBSD 14 with UTF-8 locale:

    $ printf "\201'A\n" | sed s/./x/ | hexdump -C
    00000000  81 78 41 0a                                       |.xA.|

That is, the first byte remains untouched and the ' is replaced with x.
This kind of string would result in inbalanced quotes in xzdiff. In the
C locale it works safely:

    $ printf "\201'A\n" | LC_ALL=C sed s/./x/ | hexdump -C
    00000000  78 27 41 0a                                       |x'A.|

Similar changes were made in xzgrep in 2022 (see the commits 69d1b3fc2967
and 6a4a4a7d2667). Somehow xzdiff was forgotten even though this issue
was fixed in zdiff in gzip in 2022.

Co-authored-by: rootvector2 <dxbnaveed.k@gmail.com>
Fixes: https://github.com/tukaani-project/xz/pull/228
2026-06-16 18:33:43 +03:00
rootvector2
1aab7e9cab
xz: Fix --files/--files0 usage via XZ_OPT and XZ_DEFAULTS env vars
If --files=FILELIST or --files0=FILELIST was specified via an enrivonment
variable, it worked if there were no errors when reading from the file
FILELIST. However, if an error occurred when reading from FILELIST,
there was a use-after-free bug when printing the error message because
the memory containing the string "FILELIST" had been freed.

    printf foo.xz > filelist.txt
    XZ_OPT=--files=filelist.txt xz -l

Because filelist.txt doesn't end in a newline, the file list is seen as
invalid/truncated, resulting in an error message like this:

    xz: ????????.txt: Unexpected end of input when reading filenames

The question marks are because the garbage string is masked using
tuklib_mask_nonprint(). After this commit, it works:

    xz: filelist.txt: Unexpected end of input when reading filenames

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
Fixes: https://github.com/tukaani-project/xz/pull/223
2026-05-28 13:22:55 +03:00
rootvector2
d0d380797e
xz: Mask the multiplier suffix in str_to_uint64() error message
A similar error message in the same function was masked in the
previous commit 7e7bb6c21cf9.

Fixes: https://github.com/tukaani-project/xz/pull/222
2026-05-28 12:58:25 +03:00
Lasse Collin
7e7bb6c21c
xz: Use tuklib_mbstr_nonprint in a few more places
Reported-by: GitHub user curious-rabbit
2026-05-27 13:00:11 +03:00
Lasse Collin
1df00237ae
xzgrep: Fix handling of the ' char at the end of an option
For example, the following would run the "id" command:

    xzgrep "--a='" "--b=;id;'" "pattern" foo.xz

The bug was inherited from gzip's zgrep. It was reported to bug-gzip by
Leenear. It was fixed in gzip in the commit cd74dc30f8cc by Paul Eggert.

Link: https://lists.gnu.org/archive/html/bug-gzip/2026-04/msg00032.html
2026-05-27 13:00:11 +03:00
Lasse Collin
2928248922
Update THANKS 2026-05-27 13:00:11 +03:00
Lasse Collin
8654b72980
Landlock: Support ABI version 9
Features added in versions 7 and 8 shouldn't be relevant here.
2026-05-27 13:00:11 +03:00
Lasse Collin
f5665a445f
Landlock: Provide fallbacks for ABI 2, 3, and 5 macros
This way the newer features are available on new enough kernels
even if the package is built against old <linux/landlock.h>.

Landlock ABI versions 4 and 6 would require an extended
struct landlock_ruleset_attr. No fallback is provided (or planned)
for those features.

Suggested-by: Omkhar Arasaratnam
2026-05-27 13:00:11 +03:00
Lasse Collin
6237e4319f
xz: Reduce indentation of three tables on the man page
The extra indentation makes the tables stand out from the text, and
in the English man page it works well. However, some translations
have strings that require more space, and the table might become
too wide. In some translations this has been solved by splitting
the translated string on two lines, for example, Romanian translation
of "4096-byte alignment is best".

On Debian 13 with groff 1.23.0, the "man" command shows a few warnings:

    $ LANGUAGE=it MANWIDTH=80 man --warnings xz > /dev/null
    <standard input>:477: warning: table wider than line length minus indentation
    <standard input>:545: warning: table wider than line length minus indentation
    <standard input>:1182: warning: table wider than line length minus indentation

German man page shows those warnings too. On Arch with groff 1.24.1,
there are fewer warnings because the newer groff indents less, and
fewer tables reach or exceed the right margin. Thus, some safety margin
is good to keep the output neat with different man page formatters.

It feels silly to reduce the indentation on the English man page which
has plenty of safety margin, but it's simpler than trying to do it
only for the translated man pages. This doesn't affect readability;
it's just cosmetic.

I tried using .IP instead of .RS + .PP for the tables, but on Solaris 10
it results in an extra empty line before the table. It makes some
difference on AIX 7.3 too. With groff, both are fine. Stick to
.RS + .PP + .TS ... .TE + .RE for slightly better portability.

Co-authored-by: Otto Kekäläinen <otto@debian.org>
Partially-fixes: https://github.com/tukaani-project/xz/pull/220
2026-05-27 13:00:11 +03:00
Lasse Collin
f9b243e203
Translations: Fix a syntax typo in the Serbian xz man page translation
Testing with this:

    cd po4a
    ./update-po
    groff -K utf8 -man -t -ww -rCHECKSTYLE=3 -z man/sr/*.1

The output included this:

    an.tmac:man/sr/xz.1:751: style: 1 leading space(s) on input line

The actual reason seemed to be an unwanted newline (likely a typo).
2026-05-27 13:00:11 +03:00
Lasse Collin
625387f089
Translations: Fix a groff warning in the German xz man page translation
Testing with this:

    cd po4a
    ./update-po
    groff -K utf8 -man -t -ww -rCHECKSTYLE=3 -z man/de/*.1

The output included this:

    an.tmac:man/de/xz.1:524: style: 1 leading space(s) on input line
2026-05-27 13:00:11 +03:00
Lasse Collin
6365d4dadd
Translations: Fix syntax in the Korean man page translations
Testing with this:

    cd po4a
    ./update-po
    groff -K utf8 -man -t -ww -z man/ko/*.1

It produced warnings:

    troff:man/ko/xz.1:1405: warning: color 'i' not defined
    troff:man/ko/xzdec.1:17: warning: cannot select font '\'
    troff:man/ko/xzdec.1:19: warning: cannot select font '\'
2026-05-27 13:00:11 +03:00
Lasse Collin
8e99c3934b
Translations: Fix a syntax typo in the French xz man page translation
Testing with this:

    cd po4a
    ./update-po
    groff -K utf8 -man -t -ww -z man/fr/xz.1

It produced a warning:

    troff:man/fr/xz.1:516: warning: color 'i' not defined

The backslash for non-breaking space was misplaced:

    Old:  8 \\Mio,
    New:  8\\ Mio,
2026-05-27 13:00:11 +03:00
Lasse Collin
784adc9263
Man pages: Improve rendering in mandoc
Don't use "" as an argument to .IP because it makes mandoc insert
an unwanted extra empty line. With the xz man page, this change makes
no difference in plain text output with GNU groff or on AIX or
Solaris 10. The list in the xzgrep man page has a different indentation
now because previously it had two arguments (.IP "" 4), but that's OK.

I don't remember why '.IP' was changed to '.IP ""' in cec0ddc8ec4c.
Maybe it made a difference on some proprietary UNIX over 15 years ago
or maybe it was just a misunderstanding.
2026-05-27 13:00:11 +03:00
Lasse Collin
814e8828b5
po4a/update-po: Workaround an issue with non-ASCII chars in tables
Non-ASCII chars in tables (.TS ... .TE) result in warnings:

    man --warnings po4a/man/uk/xz.1 > /dev/null
    troff:<standard input>:464: warning: special character 'u0411\[tbl' not defined
    troff:<standard input>:1157: warning: special character 'u044\[tbl' not defined
    troff:<standard input>:1682: warning: special character 'u0434\[tbl' not defined

po4a generates groff Unicode escapes like '\u0435' followed immediately
by '[' in table contexts, causing groff to interpret the full string
'u0435[tbl' as a single special character name. Fix this by inserting
a dummy character (\&) after every Unicode escape so that the bracket
is treated as literal text instead of part of the character name.

Co-authored-by: Otto Kekäläinen <otto@debian.org>
Partially-fixes: https://github.com/tukaani-project/xz/pull/220
2026-05-27 13:00:11 +03:00
Lasse Collin
bc96573a65
Translations: Update the German man page translations 2026-05-27 13:00:10 +03:00
Lasse Collin
81faa2e653
liblzma: ARM64 & LoongArch: Avoid aligned_readXXle on unaligned pointers
While most ARM64 and LoongArch processors support unaligned access,
the code wouldn't have worked on strict-align processors.

Use byte-by-byte method if the input buffer is at most 7 bytes. This
way the code works on strict-align processors too. It might not be
the very best method for tiny buffers, but it shouldn't matter in
practice (the simple implementation for big buffers isn't amazing
either because it cannot execute more than one CRC32 instruction
at a time on superscalar processors).

Reported-by: Guanni Qu
Fixes: 0ed893668554 ("liblzma: ARM64 CRC32: Align the buffer faster")
Fixes: 7baf6835cfbf ("liblzma: Speed up CRC32 calculation on 64-bit LoongArch")
2026-05-27 13:00:10 +03:00
Lasse Collin
c2fe308792
liblzma: Document the lzma_stream_buffer_decode() bug 2026-05-27 13:00:10 +03:00
Lasse Collin
6566e6251a
Tests: tuktest.h: Fix a comment 2026-05-27 13:00:10 +03:00
Lasse Collin
29584cdaf3
Tests: Add a test for the lzma_stream_buffer_decode() bug 2026-05-27 13:00:10 +03:00
Lasse Collin
b53838ae0c
liblzma: lzma_stream_buffer_decode: Fix wrong error code
lzma_stream_buffer_decode() would often fail with LZMA_BUF_ERROR
when it should have failed with LZMA_DATA_ERROR.
In debug builds this also resulted in an assertion failure.

In the _buffer_decode() functions, LZMA_BUF_ERROR is only used when
the output buffer is too small. Truncated input is LZMA_DATA_ERROR.

Reported-by: Guanni Qu
Reported-by: Omkhar Arasaratnam
Fixes: c81f13ff2927 ("Added lzma_stream_buffer_decode() and made minor cleanups.")
2026-05-27 13:00:10 +03:00
Lasse Collin
327c906dcd
xz: Fix use-after-free in verbose error message to a non-tty
If --verbose was used when stderr isn't a terminal, the filename
contained a non-printable character, and an error occurred,
a use-after-free occurred when printing the error message.

The bug exists in versions 5.7.1alpha to 5.8.3.

Reported-by: Omkhar Arasaratnam
Fixes: d22f96921fd2 ("xz: Use tuklib_mbstr_nonprint")
2026-05-27 13:00:04 +03:00
Lasse Collin
ebb0e6789c
doc/SHA256SUMS: Add 5.8.3 2026-03-31 18:41:04 +03:00
Lasse Collin
4b73f2ec19
Bump version and soname for 5.8.3 v5.8.3 2026-03-31 17:30:50 +03:00
Lasse Collin
97b7440006
Add NEWS for 5.8.3 2026-03-31 17:30:50 +03:00
Lasse Collin
8e1022cfb1
Translations: Run "make -C po update-po"
Update the PO files to contain the comment fix from 4e76651dbaf6.
2026-03-31 17:30:50 +03:00