MFV r333779: xz 5.2.4.

MFC after:	2 weeks
This commit is contained in:
Xin LI 2018-05-18 06:10:16 +00:00
commit b71a5db306
22 changed files with 382 additions and 10082 deletions

View File

@ -47,7 +47,7 @@ XZ Utils Licensing
naturally it is not legally required. Here is an example of a good naturally it is not legally required. Here is an example of a good
notice to put into "about box" or into documentation: notice to put into "about box" or into documentation:
This software includes code from XZ Utils <http://tukaani.org/xz/>. This software includes code from XZ Utils <https://tukaani.org/xz/>.
The following license texts are included in the following files: The following license texts are included in the following files:
- COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1 - COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1

File diff suppressed because it is too large Load Diff

View File

@ -291,7 +291,7 @@ XZ Utils
XZ Embedded is a limited implementation written for use in the Linux XZ Embedded is a limited implementation written for use in the Linux
kernel, but it is also suitable for other embedded use. kernel, but it is also suitable for other embedded use.
http://tukaani.org/xz/embedded.html https://tukaani.org/xz/embedded.html
6. Contact information 6. Contact information

View File

@ -11,7 +11,9 @@ has been important. :-) In alphabetical order:
- Karl Berry - Karl Berry
- Anders F. Björklund - Anders F. Björklund
- Emmanuel Blot - Emmanuel Blot
- Melanie Blower
- Martin Blumenstingl - Martin Blumenstingl
- Ben Boeckel
- Jakub Bogusz - Jakub Bogusz
- Maarten Bosmans - Maarten Bosmans
- Trent W. Buck - Trent W. Buck
@ -56,6 +58,7 @@ has been important. :-) In alphabetical order:
- Andraž 'ruskie' Levstik - Andraž 'ruskie' Levstik
- Cary Lewis - Cary Lewis
- Wim Lewis - Wim Lewis
- Eric Lindblad
- Lorenzo De Liso - Lorenzo De Liso
- Bela Lubkin - Bela Lubkin
- Gregory Margo - Gregory Margo
@ -93,6 +96,7 @@ has been important. :-) In alphabetical order:
- Stuart Shelton - Stuart Shelton
- Sebastian Andrzej Siewior - Sebastian Andrzej Siewior
- Brad Smith - Brad Smith
- Pippijn van Steenhoven
- Jonathan Stott - Jonathan Stott
- Dan Stromberg - Dan Stromberg
- Vincent Torri - Vincent Torri

View File

@ -98,6 +98,17 @@
#endif #endif
////////////////////////////////
// Compiler-specific features //
////////////////////////////////
// Newer Intel C compilers require immintrin.h for _bit_scan_reverse()
// and such functions.
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
# include <immintrin.h>
#endif
/////////////////// ///////////////////
// Byte swapping // // Byte swapping //
/////////////////// ///////////////////

View File

@ -219,7 +219,11 @@
*/ */
#ifndef lzma_nothrow #ifndef lzma_nothrow
# if defined(__cplusplus) # if defined(__cplusplus)
# define lzma_nothrow throw() # if __cplusplus >= 201103L
# define lzma_nothrow noexcept
# else
# define lzma_nothrow throw()
# endif
# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) # elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
# define lzma_nothrow __attribute__((__nothrow__)) # define lzma_nothrow __attribute__((__nothrow__))
# else # else

View File

@ -644,11 +644,16 @@ extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
* This function is supported only when *strm has been initialized with * This function is supported only when *strm has been initialized with
* a function that takes a memlimit argument. * a function that takes a memlimit argument.
* *
* liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes
* this function to do nothing (leaving the limit unchanged) and still
* return LZMA_OK. Later versions treat 0 as if 1 had been specified (so
* lzma_memlimit_get() will return 1 even if you specify 0 here).
*
* \return - LZMA_OK: New memory usage limit successfully set. * \return - LZMA_OK: New memory usage limit successfully set.
* - LZMA_MEMLIMIT_ERROR: The new limit is too small. * - LZMA_MEMLIMIT_ERROR: The new limit is too small.
* The limit was not changed. * The limit was not changed.
* - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
* support memory usage limit or memlimit was zero. * support memory usage limit.
*/ */
extern LZMA_API(lzma_ret) lzma_memlimit_set( extern LZMA_API(lzma_ret) lzma_memlimit_set(
lzma_stream *strm, uint64_t memlimit) lzma_nothrow; lzma_stream *strm, uint64_t memlimit) lzma_nothrow;

View File

@ -520,7 +520,10 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
* *
* \param strm Pointer to properly prepared lzma_stream * \param strm Pointer to properly prepared lzma_stream
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX * \param memlimit Memory usage limit as bytes. Use UINT64_MAX
* to effectively disable the limiter. * to effectively disable the limiter. liblzma
* 5.2.3 and earlier don't allow 0 here and return
* LZMA_PROG_ERROR; later versions treat 0 as if 1
* had been specified.
* \param flags Bitwise-or of zero or more of the decoder flags: * \param flags Bitwise-or of zero or more of the decoder flags:
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
* LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
@ -544,7 +547,10 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder(
* *
* \param strm Pointer to properly prepared lzma_stream * \param strm Pointer to properly prepared lzma_stream
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX * \param memlimit Memory usage limit as bytes. Use UINT64_MAX
* to effectively disable the limiter. * to effectively disable the limiter. liblzma
* 5.2.3 and earlier don't allow 0 here and return
* LZMA_PROG_ERROR; later versions treat 0 as if 1
* had been specified.
* \param flags Bitwise-or of flags, or zero for no flags. * \param flags Bitwise-or of flags, or zero for no flags.
* *
* \return - LZMA_OK: Initialization was successful. * \return - LZMA_OK: Initialization was successful.
@ -560,9 +566,16 @@ extern LZMA_API(lzma_ret) lzma_auto_decoder(
/** /**
* \brief Initialize .lzma decoder (legacy file format) * \brief Initialize .lzma decoder (legacy file format)
* *
* \param strm Pointer to properly prepared lzma_stream
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
* to effectively disable the limiter. liblzma
* 5.2.3 and earlier don't allow 0 here and return
* LZMA_PROG_ERROR; later versions treat 0 as if 1
* had been specified.
*
* Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
* There is no need to use LZMA_FINISH, but allowing it may simplify * There is no need to use LZMA_FINISH, but it's allowed because it may
* certain types of applications. * simplify certain types of applications.
* *
* \return - LZMA_OK * \return - LZMA_OK
* - LZMA_MEM_ERROR * - LZMA_MEM_ERROR

View File

@ -586,8 +586,7 @@ extern LZMA_API(lzma_index *) lzma_index_dup(
* \param i Pointer to lzma_index which should be encoded. * \param i Pointer to lzma_index which should be encoded.
* *
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
* It is enough to use only one of them (you can choose freely; use LZMA_RUN * It is enough to use only one of them (you can choose freely).
* to support liblzma versions older than 5.0.0).
* *
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
* - LZMA_MEM_ERROR * - LZMA_MEM_ERROR
@ -610,16 +609,21 @@ extern LZMA_API(lzma_ret) lzma_index_encoder(
* to a new lzma_index, which the application * to a new lzma_index, which the application
* has to later free with lzma_index_end(). * has to later free with lzma_index_end().
* \param memlimit How much memory the resulting lzma_index is * \param memlimit How much memory the resulting lzma_index is
* allowed to require. * allowed to require. liblzma 5.2.3 and earlier
* don't allow 0 here and return LZMA_PROG_ERROR;
* later versions treat 0 as if 1 had been specified.
* *
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
* It is enough to use only one of them (you can choose freely; use LZMA_RUN * There is no need to use LZMA_FINISH, but it's allowed because it may
* to support liblzma versions older than 5.0.0). * simplify certain types of applications.
* *
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
* - LZMA_MEM_ERROR * - LZMA_MEM_ERROR
* - LZMA_MEMLIMIT_ERROR
* - LZMA_PROG_ERROR * - LZMA_PROG_ERROR
*
* liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here
* but that error code has never been possible from this
* initialization function.
*/ */
extern LZMA_API(lzma_ret) lzma_index_decoder( extern LZMA_API(lzma_ret) lzma_index_decoder(
lzma_stream *strm, lzma_index **i, uint64_t memlimit) lzma_stream *strm, lzma_index **i, uint64_t memlimit)

View File

@ -22,7 +22,7 @@
*/ */
#define LZMA_VERSION_MAJOR 5 #define LZMA_VERSION_MAJOR 5
#define LZMA_VERSION_MINOR 2 #define LZMA_VERSION_MINOR 2
#define LZMA_VERSION_PATCH 3 #define LZMA_VERSION_PATCH 4
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
#ifndef LZMA_VERSION_COMMIT #ifndef LZMA_VERSION_COMMIT

View File

@ -203,9 +203,6 @@ lzma_alone_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
{ {
lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator); lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator);
if (memlimit == 0)
return LZMA_PROG_ERROR;
lzma_alone_coder *coder = next->coder; lzma_alone_coder *coder = next->coder;
if (coder == NULL) { if (coder == NULL) {
@ -227,7 +224,7 @@ lzma_alone_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
coder->options.preset_dict = NULL; coder->options.preset_dict = NULL;
coder->options.preset_dict_size = 0; coder->options.preset_dict_size = 0;
coder->uncompressed_size = 0; coder->uncompressed_size = 0;
coder->memlimit = memlimit; coder->memlimit = my_max(1, memlimit);
coder->memusage = LZMA_MEMUSAGE_BASE; coder->memusage = LZMA_MEMUSAGE_BASE;
return LZMA_OK; return LZMA_OK;

View File

@ -139,7 +139,10 @@ auto_decoder_memconfig(void *coder_ptr, uint64_t *memusage,
// the current memory usage. // the current memory usage.
*memusage = LZMA_MEMUSAGE_BASE; *memusage = LZMA_MEMUSAGE_BASE;
*old_memlimit = coder->memlimit; *old_memlimit = coder->memlimit;
ret = LZMA_OK; ret = LZMA_OK;
if (new_memlimit != 0 && new_memlimit < *memusage)
ret = LZMA_MEMLIMIT_ERROR;
} }
if (ret == LZMA_OK && new_memlimit != 0) if (ret == LZMA_OK && new_memlimit != 0)
@ -155,9 +158,6 @@ auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
{ {
lzma_next_coder_init(&auto_decoder_init, next, allocator); lzma_next_coder_init(&auto_decoder_init, next, allocator);
if (memlimit == 0)
return LZMA_PROG_ERROR;
if (flags & ~LZMA_SUPPORTED_FLAGS) if (flags & ~LZMA_SUPPORTED_FLAGS)
return LZMA_OPTIONS_ERROR; return LZMA_OPTIONS_ERROR;
@ -175,7 +175,7 @@ auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
coder->next = LZMA_NEXT_CODER_INIT; coder->next = LZMA_NEXT_CODER_INIT;
} }
coder->memlimit = memlimit; coder->memlimit = my_max(1, memlimit);
coder->flags = flags; coder->flags = flags;
coder->sequence = SEQ_INIT; coder->sequence = SEQ_INIT;

View File

@ -435,8 +435,10 @@ lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit)
|| strm->internal->next.memconfig == NULL) || strm->internal->next.memconfig == NULL)
return LZMA_PROG_ERROR; return LZMA_PROG_ERROR;
if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE) // Zero is a special value that cannot be used as an actual limit.
return LZMA_MEMLIMIT_ERROR; // If 0 was specified, use 1 instead.
if (new_memlimit == 0)
new_memlimit = 1;
return strm->internal->next.memconfig(strm->internal->next.coder, return strm->internal->next.memconfig(strm->internal->next.coder,
&memusage, &old_memlimit, new_memlimit); &memusage, &old_memlimit, new_memlimit);

View File

@ -256,7 +256,7 @@ index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator,
// Initialize the rest. // Initialize the rest.
coder->sequence = SEQ_INDICATOR; coder->sequence = SEQ_INDICATOR;
coder->memlimit = memlimit; coder->memlimit = my_max(1, memlimit);
coder->count = 0; // Needs to be initialized due to _memconfig(). coder->count = 0; // Needs to be initialized due to _memconfig().
coder->pos = 0; coder->pos = 0;
coder->crc32 = 0; coder->crc32 = 0;
@ -271,7 +271,7 @@ index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
{ {
lzma_next_coder_init(&index_decoder_init, next, allocator); lzma_next_coder_init(&index_decoder_init, next, allocator);
if (i == NULL || memlimit == 0) if (i == NULL)
return LZMA_PROG_ERROR; return LZMA_PROG_ERROR;
lzma_index_coder *coder = next->coder; lzma_index_coder *coder = next->coder;

View File

@ -422,9 +422,6 @@ lzma_stream_decoder_init(
{ {
lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator); lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator);
if (memlimit == 0)
return LZMA_PROG_ERROR;
if (flags & ~LZMA_SUPPORTED_FLAGS) if (flags & ~LZMA_SUPPORTED_FLAGS)
return LZMA_OPTIONS_ERROR; return LZMA_OPTIONS_ERROR;
@ -444,7 +441,7 @@ lzma_stream_decoder_init(
coder->index_hash = NULL; coder->index_hash = NULL;
} }
coder->memlimit = memlimit; coder->memlimit = my_max(1, memlimit);
coder->memusage = LZMA_MEMUSAGE_BASE; coder->memusage = LZMA_MEMUSAGE_BASE;
coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0; coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
coder->tell_unsupported_check coder->tell_unsupported_check

View File

@ -16,6 +16,12 @@
#include "lzma_decoder.h" #include "lzma_decoder.h"
#include "range_decoder.h" #include "range_decoder.h"
// The macros unroll loops with switch statements.
// Silence warnings about missing fall-through comments.
#if TUKLIB_GNUC_REQ(7, 0)
# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
#ifdef HAVE_SMALL #ifdef HAVE_SMALL

View File

@ -14,9 +14,7 @@
#ifndef LZMA_RANGE_COMMON_H #ifndef LZMA_RANGE_COMMON_H
#define LZMA_RANGE_COMMON_H #define LZMA_RANGE_COMMON_H
#ifdef HAVE_CONFIG_H #include "common.h"
# include "common.h"
#endif
/////////////// ///////////////

View File

@ -525,7 +525,10 @@ io_open_src_real(file_pair *pair)
#endif #endif
#ifdef HAVE_POSIX_FADVISE #ifdef HAVE_POSIX_FADVISE
// It will fail if stdin is a pipe and that's fine. // It will fail if stdin is a pipe and that's fine.
(void)posix_fadvise(STDIN_FILENO, 0, 0, POSIX_FADV_SEQUENTIAL); (void)posix_fadvise(STDIN_FILENO, 0, 0,
opt_mode == MODE_LIST
? POSIX_FADV_RANDOM
: POSIX_FADV_SEQUENTIAL);
#endif #endif
return false; return false;
} }
@ -716,7 +719,10 @@ io_open_src_real(file_pair *pair)
#ifdef HAVE_POSIX_FADVISE #ifdef HAVE_POSIX_FADVISE
// It will fail with some special files like FIFOs but that is fine. // It will fail with some special files like FIFOs but that is fine.
(void)posix_fadvise(pair->src_fd, 0, 0, POSIX_FADV_SEQUENTIAL); (void)posix_fadvise(pair->src_fd, 0, 0,
opt_mode == MODE_LIST
? POSIX_FADV_RANDOM
: POSIX_FADV_SEQUENTIAL);
#endif #endif
return false; return false;

View File

@ -109,7 +109,7 @@ static struct {
uint32_t checks; uint32_t checks;
uint32_t min_version; uint32_t min_version;
bool all_have_sizes; bool all_have_sizes;
} totals = { 0, 0, 0, 0, 0, 0, 0, 0, 0, true }; } totals = { 0, 0, 0, 0, 0, 0, 0, 0, 50000002, true };
/// Convert XZ Utils version number to a string. /// Convert XZ Utils version number to a string.
@ -484,6 +484,8 @@ parse_block_header(file_pair *pair, const lzma_index_iter *iter,
// If the above fails, the file is corrupt so // If the above fails, the file is corrupt so
// LZMA_DATA_ERROR is a good error code. // LZMA_DATA_ERROR is a good error code.
// Fall through
case LZMA_DATA_ERROR: case LZMA_DATA_ERROR:
// Free the memory allocated by lzma_block_header_decode(). // Free the memory allocated by lzma_block_header_decode().
for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i)
@ -636,7 +638,11 @@ static void
get_check_names(char buf[CHECKS_STR_SIZE], get_check_names(char buf[CHECKS_STR_SIZE],
uint32_t checks, bool space_after_comma) uint32_t checks, bool space_after_comma)
{ {
assert(checks != 0); // If we get called when there are no Checks to print, set checks
// to 1 so that we print "None". This can happen in the robot mode
// when printing the totals line if there are no valid input files.
if (checks == 0)
checks = 1;
char *pos = buf; char *pos = buf;
size_t left = CHECKS_STR_SIZE; size_t left = CHECKS_STR_SIZE;

View File

@ -5,7 +5,7 @@
.\" This file has been put into the public domain. .\" This file has been put into the public domain.
.\" You can do whatever you want with this file. .\" You can do whatever you want with this file.
.\" .\"
.TH XZ 1 "2015-05-11" "Tukaani" "XZ Utils" .TH XZ 1 "2017-04-19" "Tukaani" "XZ Utils"
. .
.SH NAME .SH NAME
xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
@ -2779,8 +2779,8 @@ have the same number of bytes per pixel.
.BR bzip2 (1), .BR bzip2 (1),
.BR 7z (1) .BR 7z (1)
.PP .PP
XZ Utils: <http://tukaani.org/xz/> XZ Utils: <https://tukaani.org/xz/>
.br .br
XZ Embedded: <http://tukaani.org/xz/embedded.html> XZ Embedded: <https://tukaani.org/xz/embedded.html>
.br .br
LZMA SDK: <http://7-zip.org/sdk.html> LZMA SDK: <http://7-zip.org/sdk.html>

View File

@ -4,7 +4,7 @@
.\" This file has been put into the public domain. .\" This file has been put into the public domain.
.\" You can do whatever you want with this file. .\" You can do whatever you want with this file.
.\" .\"
.TH XZDEC 1 "2013-06-30" "Tukaani" "XZ Utils" .TH XZDEC 1 "2017-04-19" "Tukaani" "XZ Utils"
.SH NAME .SH NAME
xzdec, lzmadec \- Small .xz and .lzma decompressors xzdec, lzmadec \- Small .xz and .lzma decompressors
.SH SYNOPSIS .SH SYNOPSIS
@ -143,4 +143,4 @@ decompressor, consider using XZ Embedded.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR xz (1) .BR xz (1)
.PP .PP
XZ Embedded: <http://tukaani.org/xz/embedded.html> XZ Embedded: <https://tukaani.org/xz/embedded.html>

View File

@ -335,16 +335,16 @@
#define PACKAGE_NAME "XZ Utils" #define PACKAGE_NAME "XZ Utils"
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#define PACKAGE_STRING "XZ Utils 5.2.3" #define PACKAGE_STRING "XZ Utils 5.2.4"
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "xz" #define PACKAGE_TARNAME "xz"
/* Define to the home page for this package. */ /* Define to the home page for this package. */
#define PACKAGE_URL "http://tukaani.org/xz/" #define PACKAGE_URL "https://tukaani.org/xz/"
/* Define to the version of this package. */ /* Define to the version of this package. */
#define PACKAGE_VERSION "5.2.3" #define PACKAGE_VERSION "5.2.4"
/* Define to necessary symbol if this constant uses a non-standard name on /* Define to necessary symbol if this constant uses a non-standard name on
your system. */ your system. */
@ -432,7 +432,7 @@
/* Version number of package */ /* Version number of package */
#define VERSION "5.2.3" #define VERSION "5.2.4"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */ significant byte first (like Motorola and SPARC, unlike Intel). */