diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/tuklib_integer.h | 11 | ||||
-rw-r--r-- | src/liblzma/api/lzma.h | 6 | ||||
-rw-r--r-- | src/liblzma/api/lzma/base.h | 7 | ||||
-rw-r--r-- | src/liblzma/api/lzma/container.h | 21 | ||||
-rw-r--r-- | src/liblzma/api/lzma/index.h | 18 | ||||
-rw-r--r-- | src/liblzma/api/lzma/version.h | 2 | ||||
-rw-r--r-- | src/liblzma/common/alone_decoder.c | 5 | ||||
-rw-r--r-- | src/liblzma/common/auto_decoder.c | 8 | ||||
-rw-r--r-- | src/liblzma/common/common.c | 6 | ||||
-rw-r--r-- | src/liblzma/common/index_decoder.c | 4 | ||||
-rw-r--r-- | src/liblzma/common/stream_decoder.c | 5 | ||||
-rw-r--r-- | src/liblzma/lzma/lzma_decoder.c | 6 | ||||
-rw-r--r-- | src/liblzma/rangecoder/range_common.h | 4 | ||||
-rw-r--r-- | src/xz/file_io.c | 10 | ||||
-rw-r--r-- | src/xz/list.c | 10 | ||||
-rw-r--r-- | src/xz/xz.1 | 6 | ||||
-rw-r--r-- | src/xzdec/xzdec.1 | 4 |
17 files changed, 91 insertions, 42 deletions
diff --git a/src/common/tuklib_integer.h b/src/common/tuklib_integer.h index a7fda67966c7..b1e84d5c1d0c 100644 --- a/src/common/tuklib_integer.h +++ b/src/common/tuklib_integer.h @@ -98,6 +98,17 @@ #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 // /////////////////// diff --git a/src/liblzma/api/lzma.h b/src/liblzma/api/lzma.h index ce675a788716..aa88e4243a29 100644 --- a/src/liblzma/api/lzma.h +++ b/src/liblzma/api/lzma.h @@ -219,7 +219,11 @@ */ #ifndef lzma_nothrow # 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) # define lzma_nothrow __attribute__((__nothrow__)) # else diff --git a/src/liblzma/api/lzma/base.h b/src/liblzma/api/lzma/base.h index 7a31a4205136..a6005accc93d 100644 --- a/src/liblzma/api/lzma/base.h +++ b/src/liblzma/api/lzma/base.h @@ -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 * 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. * - LZMA_MEMLIMIT_ERROR: The new limit is too small. * The limit was not changed. * - 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( lzma_stream *strm, uint64_t memlimit) lzma_nothrow; diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h index 86991add1967..9fbf4df06178 100644 --- a/src/liblzma/api/lzma/container.h +++ b/src/liblzma/api/lzma/container.h @@ -520,7 +520,10 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * * \param strm Pointer to properly prepared lzma_stream * \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: * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, * 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 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. * * \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) * + * \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. - * There is no need to use LZMA_FINISH, but allowing it may simplify - * certain types of applications. + * There is no need to use LZMA_FINISH, but it's allowed because it may + * simplify certain types of applications. * * \return - LZMA_OK * - LZMA_MEM_ERROR diff --git a/src/liblzma/api/lzma/index.h b/src/liblzma/api/lzma/index.h index dda60ec1c185..3dac6fb85ccb 100644 --- a/src/liblzma/api/lzma/index.h +++ b/src/liblzma/api/lzma/index.h @@ -586,8 +586,7 @@ extern LZMA_API(lzma_index *) lzma_index_dup( * \param i Pointer to lzma_index which should be encoded. * * 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 - * to support liblzma versions older than 5.0.0). + * It is enough to use only one of them (you can choose freely). * * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR @@ -610,16 +609,21 @@ extern LZMA_API(lzma_ret) lzma_index_encoder( * to a new lzma_index, which the application * has to later free with lzma_index_end(). * \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. - * It is enough to use only one of them (you can choose freely; use LZMA_RUN - * to support liblzma versions older than 5.0.0). + * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. + * There is no need to use LZMA_FINISH, but it's allowed because it may + * simplify certain types of applications. * * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_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( lzma_stream *strm, lzma_index **i, uint64_t memlimit) diff --git a/src/liblzma/api/lzma/version.h b/src/liblzma/api/lzma/version.h index b5e061c26801..143c7dea69f5 100644 --- a/src/liblzma/api/lzma/version.h +++ b/src/liblzma/api/lzma/version.h @@ -22,7 +22,7 @@ */ #define LZMA_VERSION_MAJOR 5 #define LZMA_VERSION_MINOR 2 -#define LZMA_VERSION_PATCH 3 +#define LZMA_VERSION_PATCH 4 #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #ifndef LZMA_VERSION_COMMIT diff --git a/src/liblzma/common/alone_decoder.c b/src/liblzma/common/alone_decoder.c index dd681765423e..77d0a9b1002c 100644 --- a/src/liblzma/common/alone_decoder.c +++ b/src/liblzma/common/alone_decoder.c @@ -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); - if (memlimit == 0) - return LZMA_PROG_ERROR; - lzma_alone_coder *coder = next->coder; 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_size = 0; coder->uncompressed_size = 0; - coder->memlimit = memlimit; + coder->memlimit = my_max(1, memlimit); coder->memusage = LZMA_MEMUSAGE_BASE; return LZMA_OK; diff --git a/src/liblzma/common/auto_decoder.c b/src/liblzma/common/auto_decoder.c index 09acd6dc0958..6895c7ccf7b5 100644 --- a/src/liblzma/common/auto_decoder.c +++ b/src/liblzma/common/auto_decoder.c @@ -139,7 +139,10 @@ auto_decoder_memconfig(void *coder_ptr, uint64_t *memusage, // the current memory usage. *memusage = LZMA_MEMUSAGE_BASE; *old_memlimit = coder->memlimit; + ret = LZMA_OK; + if (new_memlimit != 0 && new_memlimit < *memusage) + ret = LZMA_MEMLIMIT_ERROR; } 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); - if (memlimit == 0) - return LZMA_PROG_ERROR; - if (flags & ~LZMA_SUPPORTED_FLAGS) 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->memlimit = memlimit; + coder->memlimit = my_max(1, memlimit); coder->flags = flags; coder->sequence = SEQ_INIT; diff --git a/src/liblzma/common/common.c b/src/liblzma/common/common.c index 28aa2b7142f4..57e3f8ebd62a 100644 --- a/src/liblzma/common/common.c +++ b/src/liblzma/common/common.c @@ -435,8 +435,10 @@ lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit) || strm->internal->next.memconfig == NULL) return LZMA_PROG_ERROR; - if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE) - return LZMA_MEMLIMIT_ERROR; + // Zero is a special value that cannot be used as an actual limit. + // If 0 was specified, use 1 instead. + if (new_memlimit == 0) + new_memlimit = 1; return strm->internal->next.memconfig(strm->internal->next.coder, &memusage, &old_memlimit, new_memlimit); diff --git a/src/liblzma/common/index_decoder.c b/src/liblzma/common/index_decoder.c index 1e33f0b0eb68..cc07a1b8c533 100644 --- a/src/liblzma/common/index_decoder.c +++ b/src/liblzma/common/index_decoder.c @@ -256,7 +256,7 @@ index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator, // Initialize the rest. coder->sequence = SEQ_INDICATOR; - coder->memlimit = memlimit; + coder->memlimit = my_max(1, memlimit); coder->count = 0; // Needs to be initialized due to _memconfig(). coder->pos = 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); - if (i == NULL || memlimit == 0) + if (i == NULL) return LZMA_PROG_ERROR; lzma_index_coder *coder = next->coder; diff --git a/src/liblzma/common/stream_decoder.c b/src/liblzma/common/stream_decoder.c index 7ae7a670a46a..fdd8ff2f9a3e 100644 --- a/src/liblzma/common/stream_decoder.c +++ b/src/liblzma/common/stream_decoder.c @@ -422,9 +422,6 @@ lzma_stream_decoder_init( { lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator); - if (memlimit == 0) - return LZMA_PROG_ERROR; - if (flags & ~LZMA_SUPPORTED_FLAGS) return LZMA_OPTIONS_ERROR; @@ -444,7 +441,7 @@ lzma_stream_decoder_init( coder->index_hash = NULL; } - coder->memlimit = memlimit; + coder->memlimit = my_max(1, memlimit); coder->memusage = LZMA_MEMUSAGE_BASE; coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0; coder->tell_unsupported_check diff --git a/src/liblzma/lzma/lzma_decoder.c b/src/liblzma/lzma/lzma_decoder.c index eedc0733f9b3..d0f29b763a3c 100644 --- a/src/liblzma/lzma/lzma_decoder.c +++ b/src/liblzma/lzma/lzma_decoder.c @@ -16,6 +16,12 @@ #include "lzma_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 diff --git a/src/liblzma/rangecoder/range_common.h b/src/liblzma/rangecoder/range_common.h index 0e6424198d13..2c74dc1537c8 100644 --- a/src/liblzma/rangecoder/range_common.h +++ b/src/liblzma/rangecoder/range_common.h @@ -14,9 +14,7 @@ #ifndef LZMA_RANGE_COMMON_H #define LZMA_RANGE_COMMON_H -#ifdef HAVE_CONFIG_H -# include "common.h" -#endif +#include "common.h" /////////////// diff --git a/src/xz/file_io.c b/src/xz/file_io.c index c01f4e8bb99d..041bed88e006 100644 --- a/src/xz/file_io.c +++ b/src/xz/file_io.c @@ -525,7 +525,10 @@ io_open_src_real(file_pair *pair) #endif #ifdef HAVE_POSIX_FADVISE // 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 return false; } @@ -716,7 +719,10 @@ io_open_src_real(file_pair *pair) #ifdef HAVE_POSIX_FADVISE // 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 return false; diff --git a/src/xz/list.c b/src/xz/list.c index 449c2bc4e02f..18fdca21763c 100644 --- a/src/xz/list.c +++ b/src/xz/list.c @@ -109,7 +109,7 @@ static struct { uint32_t checks; uint32_t min_version; 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. @@ -484,6 +484,8 @@ parse_block_header(file_pair *pair, const lzma_index_iter *iter, // If the above fails, the file is corrupt so // LZMA_DATA_ERROR is a good error code. + // Fall through + case LZMA_DATA_ERROR: // Free the memory allocated by lzma_block_header_decode(). 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], 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; size_t left = CHECKS_STR_SIZE; diff --git a/src/xz/xz.1 b/src/xz/xz.1 index bc5514d534d0..9dffdc6f82be 100644 --- a/src/xz/xz.1 +++ b/src/xz/xz.1 @@ -5,7 +5,7 @@ .\" This file has been put into the public domain. .\" 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 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 7z (1) .PP -XZ Utils: <http://tukaani.org/xz/> +XZ Utils: <https://tukaani.org/xz/> .br -XZ Embedded: <http://tukaani.org/xz/embedded.html> +XZ Embedded: <https://tukaani.org/xz/embedded.html> .br LZMA SDK: <http://7-zip.org/sdk.html> diff --git a/src/xzdec/xzdec.1 b/src/xzdec/xzdec.1 index 1e5ced945aae..78bc9b4a9813 100644 --- a/src/xzdec/xzdec.1 +++ b/src/xzdec/xzdec.1 @@ -4,7 +4,7 @@ .\" This file has been put into the public domain. .\" 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 xzdec, lzmadec \- Small .xz and .lzma decompressors .SH SYNOPSIS @@ -143,4 +143,4 @@ decompressor, consider using XZ Embedded. .SH "SEE ALSO" .BR xz (1) .PP -XZ Embedded: <http://tukaani.org/xz/embedded.html> +XZ Embedded: <https://tukaani.org/xz/embedded.html> |