Skip to content

Commit 46780ea

Browse files
committed
Vendor import of xz 5.2.9 (trimmed)
1 parent bbf0e6b commit 46780ea

13 files changed

+274
-28
lines changed

AUTHORS

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Authors of XZ Utils
66
77

88
Major parts of liblzma are based on code written by Igor Pavlov,
9-
specifically the LZMA SDK <http://7-zip.org/sdk.html>. Without
9+
specifically the LZMA SDK <https://7-zip.org/sdk.html>. Without
1010
this code, XZ Utils wouldn't exist.
1111

1212
The SHA-256 implementation in liblzma is based on the code found from
13-
7-Zip <http://7-zip.org/>, which has a modified version of the SHA-256
14-
code found from Crypto++ <http://www.cryptopp.com/>. The SHA-256 code
13+
7-Zip <https://7-zip.org/>, which has a modified version of the SHA-256
14+
code found from Crypto++ <https://www.cryptopp.com/>. The SHA-256 code
1515
in Crypto++ was written by Kevin Springle and Wei Dai.
1616

1717
Some scripts have been adapted from gzip. The original versions

ChangeLog

+195
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,198 @@
1+
commit d8a898eb9974683bc725c49ec76722f9a8758f48
2+
Author: Lasse Collin <[email protected]>
3+
Date: 2022-11-30 18:33:05 +0200
4+
5+
Bump version and soname for 5.2.9.
6+
7+
src/liblzma/Makefile.am | 2 +-
8+
src/liblzma/api/lzma/version.h | 2 +-
9+
2 files changed, 2 insertions(+), 2 deletions(-)
10+
11+
commit efd4430e21f798e198a6ee8a368a79065139eb54
12+
Author: Lasse Collin <[email protected]>
13+
Date: 2022-11-30 18:31:16 +0200
14+
15+
Add NEWS for 5.2.9.
16+
17+
NEWS | 34 ++++++++++++++++++++++++++++++++++
18+
1 file changed, 34 insertions(+)
19+
20+
commit 2dc1bc97a562ef4d4134c8df4d344d0f403428b8
21+
Author: Lasse Collin <[email protected]>
22+
Date: 2022-11-30 18:08:34 +0200
23+
24+
Change the bug report address.
25+
26+
It forwards to me and Jia Tan.
27+
28+
Also update the IRC reference in README as #tukaani was moved
29+
to Libera Chat long ago.
30+
31+
CMakeLists.txt | 2 +-
32+
README | 11 +++++------
33+
configure.ac | 2 +-
34+
dos/config.h | 2 +-
35+
windows/README-Windows.txt | 2 +-
36+
5 files changed, 9 insertions(+), 10 deletions(-)
37+
38+
commit fb13a234d9def06cbe2b8ed88ece7db0c6d5c39f
39+
Author: Lasse Collin <[email protected]>
40+
Date: 2022-11-30 17:38:32 +0200
41+
42+
Update to HTTPS URLs in AUTHORS.
43+
44+
AUTHORS | 6 +++---
45+
1 file changed, 3 insertions(+), 3 deletions(-)
46+
47+
commit 841448e36d4455d39ff1e1115843360934e7a507
48+
Author: Lasse Collin <[email protected]>
49+
Date: 2022-11-27 01:03:16 +0200
50+
51+
liblzma: Remove two FIXME comments.
52+
53+
src/liblzma/common/filter_encoder.c | 4 ++--
54+
1 file changed, 2 insertions(+), 2 deletions(-)
55+
56+
commit b61da00c7f535bd48930a878efdf6843d804983e
57+
Author: Lasse Collin <[email protected]>
58+
Date: 2022-11-24 14:52:44 +0200
59+
60+
Build: Don't put GNU/Linux-specific symbol versions into static liblzma.
61+
62+
It not only makes no sense to put symbol versions into a static library
63+
but it can also cause breakage.
64+
65+
By default Libtool #defines PIC if building a shared library and
66+
doesn't define it for static libraries. This is documented in the
67+
Libtool manual. It can be overriden using --with-pic or --without-pic.
68+
configure.ac detects if --with-pic or --without-pic is used and then
69+
gives an error if neither --disable-shared nor --disable-static was
70+
used at the same time. Thus, in normal situations it works to build
71+
both shared and static library at the same time on GNU/Linux,
72+
only --with-pic or --without-pic requires that only one type of
73+
library is built.
74+
75+
Thanks to John Paul Adrian Glaubitz from Debian for reporting
76+
the problem that occurred on ia64:
77+
https://www.mail-archive.com/[email protected]/msg00610.html
78+
79+
CMakeLists.txt | 5 +-
80+
configure.ac | 143 +++++++++++++++++++++++++++++---------------
81+
src/liblzma/common/common.h | 12 ++++
82+
3 files changed, 111 insertions(+), 49 deletions(-)
83+
84+
commit 6c29793b3cac292b25801d011db6d8ccade50396
85+
Author: Lasse Collin <[email protected]>
86+
Date: 2022-11-24 00:02:31 +0200
87+
88+
CMake: Don't use symbol versioning with static library.
89+
90+
CMakeLists.txt | 10 +++++++---
91+
1 file changed, 7 insertions(+), 3 deletions(-)
92+
93+
commit 872623def5e3e5c7f9f14f366d908f3e012d1007
94+
Author: Lasse Collin <[email protected]>
95+
Date: 2022-11-24 01:26:37 +0200
96+
97+
liblzma: Fix another invalid free() after memory allocation failure.
98+
99+
This time it can happen when lzma_stream_encoder_mt() is used
100+
to reinitialize an existing multi-threaded Stream encoder
101+
and one of 1-4 tiny allocations in lzma_filters_copy() fail.
102+
103+
It's very similar to the previous bug
104+
10430fbf3820dafd4eafd38ec8be161a6978ed2b, happening with
105+
an array of lzma_filter structures whose old options are freed
106+
but the replacement never arrives due to a memory allocation
107+
failure in lzma_filters_copy().
108+
109+
src/liblzma/common/stream_encoder_mt.c | 4 ++++
110+
1 file changed, 4 insertions(+)
111+
112+
commit b0f8d9293ca5a0a56964695a59a098c9d1e82b99
113+
Author: Jia Tan <[email protected]>
114+
Date: 2022-05-05 20:53:42 +0800
115+
116+
liblzma: Add support for LZMA_SYNC_FLUSH in the Block encoder.
117+
118+
The documentation mentions that lzma_block_encoder() supports
119+
LZMA_SYNC_FLUSH but it was never added to supported_actions[]
120+
in the internal structure. Because of this, LZMA_SYNC_FLUSH could
121+
not be used with the Block encoder unless it was the next coder
122+
after something like stream_encoder() or stream_encoder_mt().
123+
124+
src/liblzma/common/block_encoder.c | 1 +
125+
1 file changed, 1 insertion(+)
126+
127+
commit 6997e0b5e2339025646cfaec13a3317fb340729b
128+
Author: Lasse Collin <[email protected]>
129+
Date: 2022-11-23 21:55:22 +0200
130+
131+
liblzma: Add lzma_attr_warn_unused_result to lzma_filters_copy().
132+
133+
src/liblzma/api/lzma/filter.h | 3 ++-
134+
1 file changed, 2 insertions(+), 1 deletion(-)
135+
136+
commit f94a3e34603c56c55777056bb5412bfd0e948f0b
137+
Author: Lasse Collin <[email protected]>
138+
Date: 2022-11-23 21:26:21 +0200
139+
140+
liblzma: Fix invalid free() after memory allocation failure.
141+
142+
The bug was in the single-threaded .xz Stream encoder
143+
in the code that is used for both re-initialization and for
144+
lzma_filters_update(). To trigger it, an application had
145+
to either re-initialize an existing encoder instance with
146+
lzma_stream_encoder() or use lzma_filters_update(), and
147+
then one of the 1-4 tiny allocations in lzma_filters_copy()
148+
(called from stream_encoder_update()) must fail. An error
149+
was correctly reported but the encoder state was corrupted.
150+
151+
This is related to the recent fix in
152+
f8ee61e74eb40600445fdb601c374d582e1e9c8a which is good but
153+
it wasn't enough to fix the main problem in stream_encoder.c.
154+
155+
src/liblzma/common/stream_encoder.c | 39 +++++++++++++++++++++++++++++--------
156+
1 file changed, 31 insertions(+), 8 deletions(-)
157+
158+
commit 8309385b444bce23e56256e21fb008a170434008
159+
Author: Lasse Collin <[email protected]>
160+
Date: 2022-11-22 16:37:15 +0200
161+
162+
liblzma: Fix language in a comment.
163+
164+
src/liblzma/common/stream_encoder.c | 2 +-
165+
1 file changed, 1 insertion(+), 1 deletion(-)
166+
167+
commit 5fecba6022cbbeed8103b49d79b2fb36086be72d
168+
Author: Lasse Collin <[email protected]>
169+
Date: 2022-11-22 11:20:17 +0200
170+
171+
liblzma: Fix infinite loop in LZMA encoder init with dict_size >= 2 GiB.
172+
173+
The encoder doesn't support dictionary sizes larger than 1536 MiB.
174+
This is validated, for example, when calculating the memory usage
175+
via lzma_raw_encoder_memusage(). It is also enforced by the LZ
176+
part of the encoder initialization. However, LZMA encoder with
177+
LZMA_MODE_NORMAL did an unsafe calculation with dict_size before
178+
such validation and that results in an infinite loop if dict_size
179+
was 2 << 30 or greater.
180+
181+
src/liblzma/lzma/lzma_encoder.c | 19 +++++++++++++++----
182+
1 file changed, 15 insertions(+), 4 deletions(-)
183+
184+
commit 1946b2b141d8b12c9325ba48d3a04ad8e8206750
185+
Author: Lasse Collin <[email protected]>
186+
Date: 2022-11-21 13:02:33 +0200
187+
188+
liblzma: Fix two Doxygen commands in the API headers.
189+
190+
These were caught by clang -Wdocumentation.
191+
192+
src/liblzma/api/lzma/hardware.h | 2 +-
193+
src/liblzma/api/lzma/index_hash.h | 2 +-
194+
2 files changed, 2 insertions(+), 2 deletions(-)
195+
1196
commit 5476089d9c42b9b04e92b80e1800b384a98265cb
2197
Author: Lasse Collin <[email protected]>
3198
Date: 2022-11-13 19:58:47 +0200

README

+5-6
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,10 @@ XZ Utils
226226
----------------------
227227

228228
If you have questions, bug reports, patches etc. related to XZ Utils,
229-
contact Lasse Collin <[email protected]> (in Finnish or English).
230-
I'm sometimes slow at replying. If you haven't got a reply within two
231-
weeks, assume that your email has got lost and resend it or use IRC.
229+
the project maintainers Lasse Collin and Jia Tan can be reached via
230+
232231

233-
You can find me also from #tukaani on Freenode; my nick is Larhzu.
234-
The channel tends to be pretty quiet, so just ask your question and
235-
someone may wake up.
232+
You might find Lasse also from #tukaani on Libera Chat (IRC).
233+
The nick is Larhzu. The channel tends to be pretty quiet,
234+
so just ask your question and someone might wake up.
236235

src/liblzma/api/lzma/filter.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
120120
*/
121121
extern LZMA_API(lzma_ret) lzma_filters_copy(
122122
const lzma_filter *src, lzma_filter *dest,
123-
const lzma_allocator *allocator) lzma_nothrow;
123+
const lzma_allocator *allocator)
124+
lzma_nothrow lzma_attr_warn_unused_result;
124125

125126

126127
/**

src/liblzma/api/lzma/hardware.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
5757
* If the hardware supports more than one thread per CPU core, the number
5858
* of hardware threads is returned if that information is available.
5959
*
60-
* \brief On success, the number of available CPU threads or cores is
60+
* \return On success, the number of available CPU threads or cores is
6161
* returned. If this information isn't available or an error
6262
* occurs, zero is returned.
6363
*/

src/liblzma/api/lzma/index_hash.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern LZMA_API(void) lzma_index_hash_end(
5252
/**
5353
* \brief Add a new Record to an Index hash
5454
*
55-
* \param index Pointer to a lzma_index_hash structure
55+
* \param index_hash Pointer to a lzma_index_hash structure
5656
* \param unpadded_size Unpadded Size of a Block
5757
* \param uncompressed_size Uncompressed Size of a Block
5858
*

src/liblzma/api/lzma/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
#define LZMA_VERSION_MAJOR 5
2424
#define LZMA_VERSION_MINOR 2
25-
#define LZMA_VERSION_PATCH 8
25+
#define LZMA_VERSION_PATCH 9
2626
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
2727

2828
#ifndef LZMA_VERSION_COMMIT

src/liblzma/common/block_encoder.c

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ lzma_block_encoder(lzma_stream *strm, lzma_block *block)
217217
lzma_next_strm_init(lzma_block_encoder_init, strm, block);
218218

219219
strm->internal->supported_actions[LZMA_RUN] = true;
220+
strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
220221
strm->internal->supported_actions[LZMA_FINISH] = true;
221222

222223
return LZMA_OK;

src/liblzma/common/common.h

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434

3535
#include "lzma.h"
3636

37+
// The extra symbol versioning in the C files may only be used when
38+
// building a shared library. If HAVE_SYMBOL_VERSIONS_LINUX is defined
39+
// to 2 then symbol versioning is done only if also PIC is defined.
40+
// By default Libtool defines PIC when building a shared library and
41+
// doesn't define it when building a static library but it can be
42+
// overriden with --with-pic and --without-pic. configure let's rely
43+
// on PIC if neither --with-pic or --without-pic was used.
44+
#if defined(HAVE_SYMBOL_VERSIONS_LINUX) \
45+
&& (HAVE_SYMBOL_VERSIONS_LINUX == 2 && !defined(PIC))
46+
# undef HAVE_SYMBOL_VERSIONS_LINUX
47+
#endif
48+
3749
#ifdef HAVE_SYMBOL_VERSIONS_LINUX
3850
// To keep link-time optimization (LTO, -flto) working with GCC,
3951
// the __symver__ attribute must be used instead of __asm__(".symver ...").

src/liblzma/common/filter_encoder.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const lzma_filter_encoder encoders[] = {
5959
.id = LZMA_FILTER_LZMA1,
6060
.init = &lzma_lzma_encoder_init,
6161
.memusage = &lzma_lzma_encoder_memusage,
62-
.block_size = NULL, // FIXME
62+
.block_size = NULL, // Not needed for LZMA1
6363
.props_size_get = NULL,
6464
.props_size_fixed = 5,
6565
.props_encode = &lzma_lzma_props_encode,
@@ -70,7 +70,7 @@ static const lzma_filter_encoder encoders[] = {
7070
.id = LZMA_FILTER_LZMA2,
7171
.init = &lzma_lzma2_encoder_init,
7272
.memusage = &lzma_lzma2_encoder_memusage,
73-
.block_size = &lzma_lzma2_block_size, // FIXME
73+
.block_size = &lzma_lzma2_block_size,
7474
.props_size_get = NULL,
7575
.props_size_fixed = 1,
7676
.props_encode = &lzma_lzma2_props_encode,

src/liblzma/common/stream_encoder.c

+32-9
Original file line numberDiff line numberDiff line change
@@ -233,38 +233,61 @@ stream_encoder_update(void *coder_ptr, const lzma_allocator *allocator,
233233
const lzma_filter *reversed_filters)
234234
{
235235
lzma_stream_coder *coder = coder_ptr;
236+
lzma_ret ret;
237+
238+
// Make a copy to a temporary buffer first. This way it is easier
239+
// to keep the encoder state unchanged if an error occurs with
240+
// lzma_filters_copy().
241+
lzma_filter temp[LZMA_FILTERS_MAX + 1];
242+
return_if_error(lzma_filters_copy(filters, temp, allocator));
236243

237244
if (coder->sequence <= SEQ_BLOCK_INIT) {
238245
// There is no incomplete Block waiting to be finished,
239246
// thus we can change the whole filter chain. Start by
240247
// trying to initialize the Block encoder with the new
241248
// chain. This way we detect if the chain is valid.
242249
coder->block_encoder_is_initialized = false;
243-
coder->block_options.filters = (lzma_filter *)(filters);
244-
const lzma_ret ret = block_encoder_init(coder, allocator);
250+
coder->block_options.filters = temp;
251+
ret = block_encoder_init(coder, allocator);
245252
coder->block_options.filters = coder->filters;
246253
if (ret != LZMA_OK)
247-
return ret;
254+
goto error;
248255

249256
coder->block_encoder_is_initialized = true;
250257

251258
} else if (coder->sequence <= SEQ_BLOCK_ENCODE) {
252259
// We are in the middle of a Block. Try to update only
253260
// the filter-specific options.
254-
return_if_error(coder->block_encoder.update(
261+
ret = coder->block_encoder.update(
255262
coder->block_encoder.coder, allocator,
256-
filters, reversed_filters));
263+
filters, reversed_filters);
264+
if (ret != LZMA_OK)
265+
goto error;
257266
} else {
258267
// Trying to update the filter chain when we are already
259268
// encoding Index or Stream Footer.
260-
return LZMA_PROG_ERROR;
269+
ret = LZMA_PROG_ERROR;
270+
goto error;
261271
}
262272

263-
// Free the copy of the old chain and make a copy of the new chain.
273+
// Free the options of the old chain.
264274
for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
265275
lzma_free(coder->filters[i].options, allocator);
266276

267-
return lzma_filters_copy(filters, coder->filters, allocator);
277+
// Copy the new filter chain in place.
278+
size_t j = 0;
279+
do {
280+
coder->filters[j].id = temp[j].id;
281+
coder->filters[j].options = temp[j].options;
282+
} while (temp[j++].id != LZMA_VLI_UNKNOWN);
283+
284+
return LZMA_OK;
285+
286+
error:
287+
for (size_t i = 0; temp[i].id != LZMA_VLI_UNKNOWN; ++i)
288+
lzma_free(temp[i].options, allocator);
289+
290+
return ret;
268291
}
269292

270293

@@ -319,7 +342,7 @@ stream_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
319342

320343
// Initialize the Block encoder. This way we detect unsupported
321344
// filter chains when initializing the Stream encoder instead of
322-
// giving an error after Stream Header has already written out.
345+
// giving an error after Stream Header has already been written out.
323346
return stream_encoder_update(coder, allocator, filters, NULL);
324347
}
325348

0 commit comments

Comments
 (0)