1
0
mirror of https://git.tukaani.org/xz.git synced 2025-02-20 07:28:20 +00:00

1340 Commits

Author SHA1 Message Date
Lasse Collin
ff697eb154
liblzma: CRC CLMUL: Omit is_arch_extension_supported() when not needed
On E2K the function compiles only due to compiler emulation but the
function is never used. It's cleaner to omit the function when it's
not needed even though it's a "static inline" function.

Thanks to Ilya Kurdyukov.

(cherry picked from commit 30a2d5d51006301a3ddab5ef1f5ff0a9d74dce6f)
2024-09-06 19:00:30 +03:00
Lasse Collin
a44493ec41
xz: Fix white space
(cherry picked from commit c7164b1927e3fe7cdba70ee4687e1a590a81043b)
2024-09-06 18:56:17 +03:00
Lasse Collin
5e74a6a813
liblzma: Fix a typo in a comment
Thanks to Sam James for spotting it.

Fixes: f644473a211394447824ea00518d0a214ff3f7f2
(cherry picked from commit 0a32d2072c598de281058b26dc08920fbf0cd2a1)
2024-09-06 18:56:17 +03:00
Lasse Collin
3f7edc673c
liblzma: Fix a comment indentation
(cherry picked from commit afd9b4d282a10186808c3331dad4caf79c02d55f)
2024-09-06 18:56:16 +03:00
Lasse Collin
8a9cc7ca08
liblzma: Fix white space
(cherry picked from commit 50e6bff274568c568930e15094da8217e7d47d28)
2024-09-06 18:56:16 +03:00
RainRat
b29b13082f
Fix typos
Closes: https://github.com/tukaani-project/xz/pull/124
(cherry picked from commit 9e73918a4f14be754a23f74dda45ca431939a4a0)
2024-09-06 18:51:59 +03:00
Lasse Collin
6f66155e01
tuklib_integer: Fix building on OpenBSD/sparc64 that uses GCC 4.2
GCC 4.2 doesn't have __builtin_bswap16() and friends so tuklib_integer.h
tries to use OS-specific byte swap methods instead. On OpenBSD those
macros are swap16/32/64 instead of bswap16/32/64 like on other *BSDs
and Darwin.

An alternative to "#ifdef __OpenBSD__" could be "#ifdef swap16" as it
is a macro. But since OpenBSD seems to be a special case under this
special case of "*BSDs and Darwin", checking for __OpenBSD__ seems
the more conservative choice now.

Thanks to Christian Weisgerber and Brad Smith who both submitted
the same patch a few hours apart.

Co-authored-by: Christian Weisgerber <naddy@mips.inka.de>
Co-authored-by: Brad Smith <brad@comstyle.com>
Closes: https://github.com/tukaani-project/xz/pull/126
(cherry picked from commit 04b23addf3733873667675df2439725f076c2f36)
2024-09-06 18:51:59 +03:00
Sam James
dc6b6011b4
xz: list: suppress -Wformat-nonliteral for Solaris
Solaris' GCC can't understand that our use is fine, unlike modern compilers:
```
list.c: In function 'print_totals_basic':
list.c:1191:4: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
  uint64_to_str(totals.files, 0));
  ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

It's presumably because of older gettext missing format attributes.

This is with `gcc (GCC) 7.3.0`.

(cherry picked from commit b69768c8bd1a34fde311935c551d061ba52d9a3f)
2024-09-06 18:51:56 +03:00
Lasse Collin
3ec664d3f6 Bump version and soname for 5.6.2 2024-05-29 18:03:51 +03:00
Lasse Collin
8fda5ce872 Fix typos
Thanks to xx on #tukaani.

(cherry picked from commit 4e9023857d287f624562156b60dc23d2b64c0f10)
2024-05-23 11:36:05 +03:00
Lasse Collin
2729079bcb liblzma: Fix white space
Thanks to xx on #tukaani.

(cherry picked from commit b14d08fbbc254485ace9ccfe7908674f608a62ae)
2024-05-23 11:36:05 +03:00
Lasse Collin
a289c4dfeb xz: Document the static function get_chains_memusage()
(cherry picked from commit 142e670a413a7bce1a2647f1cf1f33f8ee2dbe88)
2024-05-23 11:28:20 +03:00
Lasse Collin
6f0db31713 xz: Rename filters_memusage_max() to get_chains_memusage()
(cherry picked from commit 78e984399a64bfee5d11e7308e0bdbc1006db2ca)
2024-05-23 11:28:20 +03:00
Lasse Collin
d7e2bf7e2d xz: Rename filter_memusages to chains_memusages
(cherry picked from commit 54c3db0a83d3e67d89aba92a0957f2dce9b111a7)
2024-05-23 11:28:20 +03:00
Lasse Collin
58f200b6d1 xz: Simplify the memory usage scaling code
This is closer to what it was before the --filtersX support was added,
just extended to support for scaling all filter chains. The method
before this commit was an extended version of the original too but
it was done in a more complex way for no clear reason. In case of
an error, the complex version printed fewer informative messages
(a good thing) but it's not a sigificant benefit.

In the limit is too low even for single-threaded mode, the required
amount of memory is now reported like in 5.4.x instead of like in
5.5.1alpha - 5.6.1 which showed the original non-scaled usage. It
had been a FIXME in the old code but it's not clear what message
makes the most sense.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
(cherry picked from commit d9e1ae79ec90d6a7eafeaceaf0ece4f0c83d4417)
2024-05-23 11:28:20 +03:00
Lasse Collin
41bdc9fa5c xz: Edit comments
(cherry picked from commit 0ee56983d198b776878432703de664049b1be32e)
2024-05-23 11:28:20 +03:00
Lasse Collin
52e40c1912 xz: Rename chain_idx to chain_num
(cherry picked from commit ec82a49c3553f7206104582dbfb8b64fa433b491)
2024-05-23 11:28:20 +03:00
Lasse Collin
8a01963331 xz: Edit coding style
(cherry picked from commit a731a6993c34bbbd55abaf9c166718682b1da24f)
2024-05-23 11:28:20 +03:00
Lasse Collin
e3ad7eda74 xz: Edit comments
Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
(cherry picked from commit 32eb176b89243fce3112347fe43a8ad14a9fd2be)
2024-05-23 11:28:20 +03:00
Lasse Collin
09cabae2ab xz: Fix grammar in a comment
Fixes: cb3111e3ed84152912b5138d690c8d9f00c6ef02
(cherry picked from commit b90339f4daa510d2b1b8c550f855a99667f1d004)
2024-05-23 11:28:20 +03:00
Lasse Collin
c10b66fbf9 xz: Rename filter_memusages to encoder_memusages
(cherry picked from commit 4c0bdaf13d651b22ba13bd93f8379724d6ccdc13)
2024-05-23 11:28:20 +03:00
Lasse Collin
9132ce3564 xz: Edit coding style
(cherry picked from commit b54aa023e0ec291b06e976e5f094ab0549e7b09b)
2024-05-23 11:28:20 +03:00
Lasse Collin
d642e13874 xz: Rename filters_index to chain_num
The reason is the same as in bd0782c1f13e52cd0fd8415208e30e47004a4c68.

(cherry picked from commit 49f67d3d3f42b640a7dfc4ca04c8934f658e10ce)
2024-05-23 11:28:20 +03:00
Lasse Collin
47599f3b73 xz: Replace a few uint32_t with "unsigned" to reduce the number of casts
These hold only tiny values.

(cherry picked from commit ff9e8b3d069ecfa52ec43dcdb198542d1692a492)
2024-05-23 11:28:20 +03:00
Lasse Collin
8f5ab75c45 xz: Rename filters_used_mask to chains_used_mask
The reason is the same as in bd0782c1f13e52cd0fd8415208e30e47004a4c68.

(cherry picked from commit b5e6c1113b1ba02c282bd9163eccdb521c937a78)
2024-05-23 11:28:20 +03:00
Lasse Collin
3eb7cf9dd5 xz: Move the setting of "check" in coder_set_compression_settings()
It's more logical to do it in the beginning instead of in the middle
of the filter chain handling.

Fixes: d6af7f347077b22403133239592e478931307759
(cherry picked from commit 32500dfaadae2ea36fda2e17b49ae7d9ac1acf52)
2024-05-23 11:28:20 +03:00
Lasse Collin
067961ee0e xz: Rename "filters" to "chains"
The convention is that

    lzma_filter filters[LZMA_FILTERS_MAX + 1];

contains the filters of a single filter chain.
It was so here as well before the commit
d6af7f347077b22403133239592e478931307759.
It changes "filters" to a ten-element array of filter chains.
It's clearer to call this array-of-arrays "chains".

This also renames "filter_idx" to "chain_idx" which is used
as an index as in chains[chain_idx].

(cherry picked from commit ad146b1f42bbb678175a503a45ce525e779f9b8b)
2024-05-23 11:28:20 +03:00
Lasse Collin
6822f6f891 xz: Clean up a comment
(cherry picked from commit 5a4ae4e4d0105404184e9a82ee08f94e1b7783e0)
2024-05-23 11:28:20 +03:00
Lasse Collin
0e5e3e7bdc xz: Add clarifying assertions
(cherry picked from commit 2de80494ed9a4dc7db395a32a5efb770ce769804)
2024-05-23 11:28:20 +03:00
Lasse Collin
77bcf6b76a xz: Add a clarifying assertion
Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
(cherry picked from commit 1eaad004bf7748976324672db028e34f42802e61)
2024-05-23 11:28:20 +03:00
Lasse Collin
df3efc058a xz: Clarify a comment
(cherry picked from commit 605094329b986244833c967c04963cacc41a868d)
2024-05-23 11:28:20 +03:00
Lasse Collin
4ebfe11cd3 xz: Use the info collected in parse_block_list()
This is slightly simpler and it avoids looping through
the opt_block_list array.

(cherry picked from commit 8fac2577f2dbb9491afd8500f60d004c9071df3b)
2024-05-23 11:28:20 +03:00
Lasse Collin
bfea691361 xz: Remember the filter chains and the largest Block in parse_block_list()
(cherry picked from commit 81d350dab864b985b740742772f3b132d4c52914)
2024-05-23 11:28:20 +03:00
Lasse Collin
d4e33e7392 xz: Update a comment and initialization of filters_used_mask
(cherry picked from commit 46ab56968f7dfdac187710a1223659d832fa1565)
2024-05-23 11:28:20 +03:00
Lasse Collin
3c130737c9 xz: parse_block_list: Edit integer type casting
(cherry picked from commit e89293a0baeb8663707c6b4a74fbb310ec698a8f)
2024-05-23 11:28:20 +03:00
Lasse Collin
40c8513b4e xz: Make filter_memusages a local variable
(cherry picked from commit 87011e40c168255cd2edea129ee68c901770603b)
2024-05-23 11:28:20 +03:00
Lasse Collin
cacaf25aa7 xz: Remove unused code and simplify
opt_mode == MODE_COMPRESS isn't possible when HAVE_ENCODERS isn't
defined. Thus, when *encoding*, the message about *decoder* memory
usage is possible to show only when both encoder and decoder have
been built.

Since the message is shown only at V_DEBUG, skip the memusage
calculation if verbosity level isn't high enough.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
(cherry picked from commit 347b412a9374e0456bef9da0d7d79174c0b6f1a5)
2024-05-23 11:28:20 +03:00
Lasse Collin
3495a6b291 xz: Fix integer type from uint64_t to uint32_t
lzma_options_lzma.dict_size is uint32_t so use it here too.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
(cherry picked from commit 31358c057c9de9d6aba96bae112b2d17942de7cb)
2024-05-23 11:28:20 +03:00
Lasse Collin
1b4e7dca24 xz: Edit comments and coding style
(cherry picked from commit e4780244a17420cc95d5498cd6e02ad10eac6e5f)
2024-05-23 11:28:20 +03:00
Lasse Collin
18683525a7 xz: Omit an incorrect comment
It likely was a leftover from a development version of the code.

Fixes: 183819bfd9efac8c184d9bf123325719b7eee30f
(cherry picked from commit fe4d8b0c80eaeca3381be302eeb89aba871a7e7c)
2024-05-23 11:28:20 +03:00
Lasse Collin
005f039864 xz: Add braces to a for-statement and to an if-statement
No functional changes.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
Fixes: 479fd58d60622331fcbe48fddf756927b9f80d9a
(cherry picked from commit 9bef5b8d17dd5e009d6a6b2becc2dc535da53937)
2024-05-23 11:28:20 +03:00
Lasse Collin
34be4e6aa6 liblzma: Omit an unneeded array from the x86 filter
Fixes: 6aa2a6deeba04808a0fe4461396e7fb70277f3d4
(cherry picked from commit de06b9f0c0a3f72569829ecadbc9c0a3ef099f57)
2024-05-23 11:28:20 +03:00
Lasse Collin
f99e7c69ad xzdec: Support Landlock ABI version 4
This was added to xz in 02e3505991233901575b7eabc06b2c6c62a96899
but I forgot to do the same in xzdec.

The Landlock sandbox in xzdec could be stricter as now it's
active only for the last file being decompressed. In xz,
read-only sandbox is used for multi-file case. On the other hand,
xz doesn't go to the strictest mode when processing the last file
when more than one file was specified; xzdec does.

(cherry picked from commit 3334c71d3d4294a4f6569df3ba9bcf2443dfa501)
2024-05-23 00:13:43 +03:00
Lasse Collin
bfe9be7a46 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: 3b34851de1eaf358cf9268922fa0eeed8278d680
(cherry picked from commit 278563ef8f2b8d98d7f2c85e1a64ec1bc21d26d8)
2024-05-23 00:13:43 +03:00
Lasse Collin
882eadc5b8 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: 88ccf47205d7f3aa314d358c72ef214f10f68b43
Co-authored-by: Sam James <sam@gentoo.org>
(cherry picked from commit 77c8f60547decefca8f2d0c905d9c708c38ee8ff)
2024-05-23 00:13:43 +03:00
Lasse Collin
28e7d130cb Build: Add --enable-doxygen to generate and install API docs
It requires Doxygen. This option is disabled by default.

(cherry picked from commit e21efdf96f39378fe417479f89e97046680406f5)
2024-05-23 00:13:43 +03:00
Lasse Collin
bae288ea6f 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 71eed2520e2eecae89bade9dceea16e56cfa2ea0)
2024-05-22 14:32:36 +03:00
Sam James
493bc57c33 liblzma: outqueue: add header guard
Reported by github's codeql.

(cherry picked from commit c7ef767c49351743d8d011574abb9e200bf6b24f)
2024-05-22 14:32:36 +03:00
Sam James
cede418d4f liblzma: easy_preset: add header guard
Reported by github's codeql.

(cherry picked from commit 55dcae3056d95cb2ddb8b560c12ba7596bc79f2c)
2024-05-22 14:32:36 +03:00
Lasse Collin
6e76a25df2 tuklib_integer: Rename bswapXX to byteswapXX
The __builtin_bswapXX from GCC and Clang are preferred when
they are available. This can allow compilers to emit the x86 MOVBE
instruction instead of doing a load + byteswap as two instructions
(which would happen if the byteswapping is done in inline asm).

bswap16, bswap32, and bswap64 exist in system headers on *BSDs
and Darwin. #defining bswap16 on NetBSD results in a warning about
macro redefinition. It's safest to avoid this namespace conflict
completely.

No OS supported by tuklib_integer.h uses byteswapXX names and
a web search doesn't immediately find any obvious danger of
namespace conflicts. So let's try these still-pretty-short names
for the macros.

Thanks to Sam James for pointing out the compiler warning on
NetBSD 10.0.

(cherry picked from commit 4ffc60f32397371769b7d6b5e3ed8626292d58df)
2024-05-22 14:32:36 +03:00