diff options
author | Xin LI <delphij@FreeBSD.org> | 2017-01-06 07:54:53 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2017-01-06 07:54:53 +0000 |
commit | 1456f0f9681bbd7fdae7b683553f6c7491508c4e (patch) | |
tree | eba597031dd83153086d52b5306e39b1d7929382 /contrib/xz | |
parent | cc5bb78be1051973c6e9bc041ced7d7065d89770 (diff) | |
parent | d069dc06884b8b477d10333362d0ee4152ef2a19 (diff) | |
download | src-1456f0f9681bbd7fdae7b683553f6c7491508c4e.tar.gz src-1456f0f9681bbd7fdae7b683553f6c7491508c4e.zip |
Notes
Diffstat (limited to 'contrib/xz')
49 files changed, 1775 insertions, 1039 deletions
diff --git a/contrib/xz/ChangeLog b/contrib/xz/ChangeLog index 27d9ea4e51de..781b673b092a 100644 --- a/contrib/xz/ChangeLog +++ b/contrib/xz/ChangeLog @@ -1,3 +1,563 @@ +commit 3d566cd519017eee1a400e7961ff14058dfaf33c +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-12-30 13:26:36 +0200 + + Bump version and soname for 5.2.3. + + src/liblzma/Makefile.am | 2 +- + src/liblzma/api/lzma/version.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 053e624fe33795e779ff736f16ce44a129c829b5 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-12-30 13:25:10 +0200 + + Update NEWS for 5.2.3. + + NEWS | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +commit cae412b2b77d7fd88d187ed7659331709311f80d +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-04-01 14:45:25 +0300 + + xz: Fix the Capsicum rights on user_abort_pipe. + + src/xz/file_io.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 9ccbae41000572193b9a09e7102f9e84dc6d96de +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-12-28 21:05:22 +0200 + + Mention potential sandboxing bugs in INSTALL. + + INSTALL | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit e013a337d3de77cce24360dffe956ea2339489b6 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-11-21 20:24:50 +0200 + + liblzma: Avoid multiple definitions of lzma_coder structures. + + Only one definition was visible in a translation unit. + It avoided a few casts and temp variables but seems that + this hack doesn't work with link-time optimizations in compilers + as it's not C99/C11 compliant. + + Fixes: + http://www.mail-archive.com/xz-devel@tukaani.org/msg00279.html + + src/liblzma/common/alone_decoder.c | 44 +++++---- + src/liblzma/common/alone_encoder.c | 34 ++++--- + src/liblzma/common/auto_decoder.c | 35 ++++--- + src/liblzma/common/block_decoder.c | 41 ++++---- + src/liblzma/common/block_encoder.c | 40 ++++---- + src/liblzma/common/common.h | 18 ++-- + src/liblzma/common/index_decoder.c | 33 ++++--- + src/liblzma/common/index_encoder.c | 16 ++-- + src/liblzma/common/stream_decoder.c | 50 +++++----- + src/liblzma/common/stream_encoder.c | 56 ++++++----- + src/liblzma/common/stream_encoder_mt.c | 124 ++++++++++++++----------- + src/liblzma/delta/delta_common.c | 25 ++--- + src/liblzma/delta/delta_decoder.c | 6 +- + src/liblzma/delta/delta_encoder.c | 12 ++- + src/liblzma/delta/delta_private.h | 4 +- + src/liblzma/lz/lz_decoder.c | 60 ++++++------ + src/liblzma/lz/lz_decoder.h | 13 ++- + src/liblzma/lz/lz_encoder.c | 57 +++++++----- + src/liblzma/lz/lz_encoder.h | 9 +- + src/liblzma/lzma/lzma2_decoder.c | 32 ++++--- + src/liblzma/lzma/lzma2_encoder.c | 51 +++++----- + src/liblzma/lzma/lzma_decoder.c | 27 +++--- + src/liblzma/lzma/lzma_encoder.c | 29 +++--- + src/liblzma/lzma/lzma_encoder.h | 9 +- + src/liblzma/lzma/lzma_encoder_optimum_fast.c | 3 +- + src/liblzma/lzma/lzma_encoder_optimum_normal.c | 23 ++--- + src/liblzma/lzma/lzma_encoder_private.h | 6 +- + src/liblzma/simple/arm.c | 2 +- + src/liblzma/simple/armthumb.c | 2 +- + src/liblzma/simple/ia64.c | 2 +- + src/liblzma/simple/powerpc.c | 2 +- + src/liblzma/simple/simple_coder.c | 61 ++++++------ + src/liblzma/simple/simple_private.h | 12 +-- + src/liblzma/simple/sparc.c | 2 +- + src/liblzma/simple/x86.c | 15 +-- + 35 files changed, 532 insertions(+), 423 deletions(-) + +commit 8e0f1af3dcaec00a3879cce8ad7441edc6359d1c +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-12-26 20:50:25 +0200 + + Document --enable-sandbox configure option in INSTALL. + + INSTALL | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +commit ce2542d220de06acd618fd9f5c0a6683029fb4eb +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-03-31 22:19:34 +0300 + + xz: Add support for sandboxing with Capsicum (disabled by default). + + In the v5.2 branch this feature is considered experimental + and thus disabled by default. + + The sandboxing is used conditionally as described in main.c. + This isn't optimal but it was much easier to implement than + a full sandboxing solution and it still covers the most common + use cases where xz is writing to standard output. This should + have practically no effect on performance even with small files + as fork() isn't needed. + + C and locale libraries can open files as needed. This has been + fine in the past, but it's a problem with things like Capsicum. + io_sandbox_enter() tries to ensure that various locale-related + files have been loaded before cap_enter() is called, but it's + possible that there are other similar problems which haven't + been seen yet. + + Currently Capsicum is available on FreeBSD 10 and later + and there is a port to Linux too. + + Thanks to Loganaden Velvindron for help. + + configure.ac | 41 +++++++++++++++++++++++++++ + src/xz/Makefile.am | 2 +- + src/xz/file_io.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/xz/file_io.h | 6 ++++ + src/xz/main.c | 18 ++++++++++++ + src/xz/private.h | 4 +++ + 6 files changed, 151 insertions(+), 1 deletion(-) + +commit 3ca1d5e6320111043e19434da881065fadafa0e4 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-03-31 21:12:30 +0300 + + Fix bugs and otherwise improve ax_check_capsicum.m4. + + AU_ALIAS was removed because the new version is incompatible + with the old version. + + It no longer checks for <sys/capability.h> separately. + It's enough to test for it as part of AC_CHECK_DECL. + The defines HAVE_CAPSICUM_SYS_CAPSICUM_H and + HAVE_CAPSICUM_SYS_CAPABILITY_H were removed as unneeded. + HAVE_SYS_CAPSICUM_H from AC_CHECK_HEADERS is enough. + + It no longer does a useless search for the Capsicum library + if the header wasn't found. + + Fixed a bug in ACTION-IF-FOUND (the first argument). Specifying + the argument omitted the default action but the given action + wasn't used instead. + + AC_DEFINE([HAVE_CAPSICUM]) is now always called when Capsicum + support is found. Previously it was part of the default + ACTION-IF-FOUND which a custom action would override. Now + the default action only prepends ${CAPSICUM_LIB} to LIBS. + + The documentation was updated. + + Since there as no serial number, "#serial 2" was added. + + m4/ax_check_capsicum.m4 | 103 ++++++++++++++++++++++++------------------------ + 1 file changed, 51 insertions(+), 52 deletions(-) + +commit 5f3a742b64197fe8bedb6f05fc6ce5d177d11145 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-03-31 19:20:24 +0300 + + Add m4/ax_check_capsicum.m4 for detecting Capsicum support. + + The file was loaded from this web page: + https://github.com/google/capsicum-test/blob/dev/autoconf/m4/ax_check_capsicum.m4 + + Thanks to Loganaden Velvindron for pointing it out for me. + + m4/ax_check_capsicum.m4 | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 86 insertions(+) + +commit d74377e62b4c649e40294dd441de72c0f092e67c +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-10-12 20:29:09 +0300 + + liblzma: Fix a memory leak in error path of lzma_index_dup(). + + lzma_index_dup() calls index_dup_stream() which, in case of + an error, calls index_stream_end() to free memory allocated + by index_stream_init(). However, it illogically didn't + actually free the memory. To make it logical, the tree + handling code was modified a bit in addition to changing + index_stream_end(). + + Thanks to Evan Nemerson for the bug report. + + src/liblzma/common/index.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +commit f580732216dcf971f3f006fe8e01cd4979e1d964 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-10-24 18:53:25 +0300 + + Update THANKS. + + THANKS | 1 + + 1 file changed, 1 insertion(+) + +commit 88d7a7fd153bf1355cdf798ffdac7443d0169afc +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-10-24 18:51:36 +0300 + + tuklib_cpucores: Add support for sched_getaffinity(). + + It's available in glibc (GNU/Linux, GNU/kFreeBSD). It's better + than sysconf(_SC_NPROCESSORS_ONLN) because sched_getaffinity() + gives the number of cores available to the process instead of + the total number of cores online. + + As a side effect, this commit fixes a bug on GNU/kFreeBSD where + configure would detect the FreeBSD-specific cpuset_getaffinity() + but it wouldn't actually work because on GNU/kFreeBSD it requires + using -lfreebsd-glue when linking. Now the glibc-specific function + will be used instead. + + Thanks to Sebastian Andrzej Siewior for the original patch + and testing. + + m4/tuklib_cpucores.m4 | 30 +++++++++++++++++++++++++++++- + src/common/tuklib_cpucores.c | 9 +++++++++ + 2 files changed, 38 insertions(+), 1 deletion(-) + +commit 51baf684376903dbeddd840582bfdf9fa91b311b +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-06-30 20:27:36 +0300 + + xz: Fix copying of timestamps on Windows. + + xz used to call utime() on Windows, but its result gets lost + on close(). Using _futime() seems to work. + + Thanks to Martok for reporting the bug: + http://www.mail-archive.com/xz-devel@tukaani.org/msg00261.html + + configure.ac | 2 +- + src/xz/file_io.c | 18 ++++++++++++++++++ + 2 files changed, 19 insertions(+), 1 deletion(-) + +commit 1ddc479851139d6e8202e5835421bfe6578d9e07 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-06-16 22:46:02 +0300 + + xz: Silence warnings from -Wlogical-op. + + Thanks to Evan Nemerson. + + src/xz/file_io.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +commit be647ff5ed5a1c244a65722af6ce250259f3b14a +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-04-10 20:55:49 +0300 + + Build: Fix = to += for xz_SOURCES in src/xz/Makefile.am. + + Thanks to Christian Kujau. + + src/xz/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fb6d50c15343831f35305982cefa82053099191d +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-04-10 20:54:17 +0300 + + Build: Bump GNU Gettext version requirement to 0.19. + + It silences a few warnings and most people probably have + 0.19 even on stable distributions. + + Thanks to Christian Kujau. + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 74f8dad9f912a2993768d93d108ea2b0b2c196e0 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-03-13 20:21:49 +0200 + + liblzma: Disable external SHA-256 by default. + + This is the sane thing to do. The conflict with OpenSSL + on some OSes and especially that the OS-provided versions + can be significantly slower makes it clear that it was + a mistake to have the external SHA-256 support enabled by + default. + + Those who want it can now pass --enable-external-sha256 to + configure. INSTALL was updated with notes about OSes where + this can be a bad idea. + + The SHA-256 detection code in configure.ac had some bugs that + could lead to a build failure in some situations. These were + fixed, although it doesn't matter that much now that the + external SHA-256 is disabled by default. + + MINIX >= 3.2.0 uses NetBSD's libc and thus has SHA256_Init + in libc instead of libutil. Support for the libutil version + was removed. + + INSTALL | 36 ++++++++++++++++++++++ + configure.ac | 76 +++++++++++++++++++++++------------------------ + src/liblzma/check/check.h | 16 ++++------ + 3 files changed, 79 insertions(+), 49 deletions(-) + +commit ea7f6ff04cb5bb1498088eb09960a4c3f13dfe39 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-03-10 20:27:05 +0200 + + Update THANKS. + + THANKS | 1 + + 1 file changed, 1 insertion(+) + +commit d0e018016b311232e82d9a98dc68f1e3dabce794 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2016-03-10 20:26:49 +0200 + + Build: Avoid SHA256_Init on FreeBSD and MINIX 3. + + On FreeBSD 10 and older, SHA256_Init from libmd conflicts + with libcrypto from OpenSSL. The OpenSSL version has + different sizeof(SHA256_CTX) and it can cause weird + problems if wrong SHA256_Init gets used. + + Looking at the source, MINIX 3 seems to have a similar issue but + I'm not sure. To be safe, I disabled SHA256_Init on MINIX 3 too. + + NetBSD has SHA256_Init in libc and they had a similar problem, + but they already fixed it in 2009. + + Thanks to Jim Wilcoxson for the bug report that helped + in finding the problem. + + configure.ac | 27 +++++++++++++++++++++------ + 1 file changed, 21 insertions(+), 6 deletions(-) + +commit 5daae123915f32a4ed6dc948b831533c2d1beec3 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-08 20:16:10 +0200 + + tuklib_physmem: Hopefully silence a warning on Windows. + + src/common/tuklib_physmem.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 491acc406e098167ccb7fce0728b94c2f32cff9f +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-04 23:17:43 +0200 + + Update THANKS. + + THANKS | 1 + + 1 file changed, 1 insertion(+) + +commit 8173ff8790ad3502d04e1c07d014cb84a3b8187b +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-04 23:14:00 +0200 + + liblzma: Make Valgrind happier with optimized (gcc -O2) liblzma. + + When optimizing, GCC can reorder code so that an uninitialized + value gets used in a comparison, which makes Valgrind unhappy. + It doesn't happen when compiled with -O0, which I tend to use + when running Valgrind. + + Thanks to Rich Prohaska. I remember this being mentioned long + ago by someone else but nothing was done back then. + + src/liblzma/lz/lz_encoder.c | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 013de2b5ab8094d2c82a2771f3d143eeb656eda9 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:55:45 +0200 + + liblzma: Rename lzma_presets.c back to lzma_encoder_presets.c. + + It would be too annoying to update other build systems + just because of this. + + src/liblzma/lzma/Makefile.inc | 2 +- + src/liblzma/lzma/{lzma_presets.c => lzma_encoder_presets.c} | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit a322f70ad96de88968c2c36e6a36bc08ae30bd20 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:47:07 +0200 + + Build: Disable xzdec, lzmadec, and lzmainfo when they cannot be built. + + They all need decoder support and if that isn't available, + there's no point trying to build them. + + configure.ac | 3 +++ + 1 file changed, 3 insertions(+) + +commit 8ea49606cf6427e32319de7693eca9e43f1c8ad6 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:35:19 +0200 + + Build: Simplify $enable_{encoders,decoders} usage a bit. + + configure.ac | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 42131a25e52bfe400acfa7df93469a96bb78bb78 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:31:31 +0200 + + Windows/MSVC: Update config.h. + + windows/config.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit e9184e87cc989d14c7413e6adb3eca98f6ae0290 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:29:58 +0200 + + DOS: Update config.h. + + dos/config.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 2296778f3c9a1e3a8699973b09dd3610b8baa402 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 20:29:33 +0200 + + xz: Make xz buildable even when encoders or decoders are disabled. + + The patch is quite long but it's mostly about adding new #ifdefs + to omit code when encoders or decoders have been disabled. + + This adds two new #defines to config.h: HAVE_ENCODERS and + HAVE_DECODERS. + + configure.ac | 4 ++++ + src/xz/Makefile.am | 8 ++++++-- + src/xz/args.c | 16 ++++++++++++++++ + src/xz/coder.c | 33 +++++++++++++++++++++++++-------- + src/xz/main.c | 9 +++++++-- + src/xz/private.h | 5 ++++- + 6 files changed, 62 insertions(+), 13 deletions(-) + +commit 97a3109281e475d9cf1b5095237d672fa0ad25e5 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 18:06:40 +0200 + + Build: Build LZMA1/2 presets also when only decoder is wanted. + + People shouldn't rely on the presets when decoding raw streams, + but xz uses the presets as the starting point for raw decoder + options anyway. + + lzma_encocder_presets.c was renamed to lzma_presets.c to + make it clear it's not used solely by the encoder code. + + src/liblzma/lzma/Makefile.inc | 6 +++++- + src/liblzma/lzma/{lzma_encoder_presets.c => lzma_presets.c} | 3 ++- + 2 files changed, 7 insertions(+), 2 deletions(-) + +commit dc6b78d7f0f6fe43e9d4215146e8581feb8090e7 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 17:54:48 +0200 + + Build: Fix configure to handle LZMA1 dependency with LZMA2. + + Now it gives an error if LZMA1 encoder/decoder is missing + when LZMA2 encoder/decoder was requested. Even better would + be LZMA2 implicitly enabling LZMA1 but it would need more code. + + configure.ac | 5 ----- + 1 file changed, 5 deletions(-) + +commit 46d76c9cd3cb26a31f5ae6c3a8bbcf38e6da1add +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-03 17:41:54 +0200 + + Build: Don't omit lzma_cputhreads() unless using --disable-threads. + + Previously it was omitted if encoders were disabled + with --disable-encoders. It didn't make sense and + it also broke the build. + + src/liblzma/common/Makefile.inc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 16d68f874d89f1e4a1919786a35bbaef7d71a077 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-02 18:16:51 +0200 + + liblzma: Fix a build failure related to external SHA-256 support. + + If an appropriate header and structure were found by configure, + but a library with a usable SHA-256 functions wasn't, the build + failed. + + src/liblzma/check/check.h | 32 +++++++++++++++++++++++--------- + 1 file changed, 23 insertions(+), 9 deletions(-) + +commit d9311647fc1ab512a3394596221ab8039c00af6b +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-11-02 15:19:10 +0200 + + xz: Always close the file before trying to delete it. + + unlink() can return EBUSY in errno for open files on some + operating systems and file systems. + + src/xz/file_io.c | 25 ++++++++++++------------- + 1 file changed, 12 insertions(+), 13 deletions(-) + +commit f59c4183f3c9066626ce45dc3db4642fa603fa21 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-10-12 21:08:42 +0300 + + Update THANKS. + + THANKS | 1 + + 1 file changed, 1 insertion(+) + +commit 35f189673e280c12e4c5129f9f97e54eef3bbc04 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-10-12 21:07:41 +0300 + + Tests: Add tests for the two bugs fixed in index.c. + + tests/test_index.c | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +commit e10bfdb0fcaff12f3a6dadee51e0a022aadccb51 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-10-12 20:45:15 +0300 + + liblzma: Fix lzma_index_dup() for empty Streams. + + Stream Flags and Stream Padding weren't copied from + empty Streams. + + src/liblzma/common/index.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +commit 06f434bd8980f25ca23232eb7bb7df7e37dc8448 +Author: Lasse Collin <lasse.collin@tukaani.org> +Date: 2015-10-12 20:31:44 +0300 + + liblzma: Add a note to index.c for those using static analyzers. + + src/liblzma/common/index.c | 3 +++ + 1 file changed, 3 insertions(+) + commit 9815cdf6987ef91a85493bfcfd1ce2aaf3b47a0a Author: Lasse Collin <lasse.collin@tukaani.org> Date: 2015-09-29 13:59:35 +0300 @@ -129,11 +689,10 @@ Date: 2015-06-19 20:21:30 +0300 Windows: Update the docs. - INSTALL | 29 ++++++---- - windows/INSTALL-MSVC.txt | 47 +++++++++++++++ - windows/INSTALL-MinGW.txt | 138 ++++++++++++++++++++++++++++++++++++++++++++ - windows/INSTALL-Windows.txt | 138 -------------------------------------------- - 4 files changed, 204 insertions(+), 148 deletions(-) + INSTALL | 29 ++++++++----- + windows/INSTALL-MSVC.txt | 47 ++++++++++++++++++++++ + windows/{INSTALL-Windows.txt => INSTALL-MinGW.txt} | 2 +- + 3 files changed, 67 insertions(+), 11 deletions(-) commit 28195e4c877007cc760ecea1d17f740693d66873 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -1587,11 +2146,10 @@ Date: 2014-05-04 11:07:17 +0300 It can be confusing that two header files have the same name. The public API file is still lzma.h. - src/liblzma/api/Makefile.am | 2 +- - src/liblzma/api/lzma.h | 2 +- - src/liblzma/api/lzma/lzma.h | 420 ------------------------------------------ - src/liblzma/api/lzma/lzma12.h | 420 ++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 422 insertions(+), 422 deletions(-) + src/liblzma/api/Makefile.am | 2 +- + src/liblzma/api/lzma.h | 2 +- + src/liblzma/api/lzma/{lzma.h => lzma12.h} | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) commit 1555a9c5664afc7893a2b75e9970105437f01ef1 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -2650,20 +3208,20 @@ Date: 2012-11-19 00:10:10 -0800 with “|-”. That worked well for a while, but the version string from ‘less’ versions 448 (June, 2012) is misparsed, producing a warning: - $ xzless /tmp/test.xz; echo $? - /usr/bin/xzless: line 49: test: 456 (GNU regular expressions): \ - integer expression expected - 0 + $ xzless /tmp/test.xz; echo $? + /usr/bin/xzless: line 49: test: 456 (GNU regular expressions): \ + integer expression expected + 0 More precisely, modern ‘less’ lists the regexp implementation along with its version number, and xzless passes the entire version number with attached parenthetical phrase as a number to "test $a -gt $b", producing the above confusing message. - $ less-444 -V | head -1 - less 444 - $ less -V | head -1 - less 456 (no regular expressions) + $ less-444 -V | head -1 + less 444 + $ less -V | head -1 + less 456 (no regular expressions) So relax the pattern matched --- instead of expecting "less <number>", look for a line of the form "less <number>[ (extra parenthetical)]". @@ -3058,11 +3616,9 @@ Date: 2012-06-14 10:33:27 +0300 copied the decompressor bug from xz_pipe_decomp.c he has an example how to easily fix it. - doc/examples/xz_pipe_comp.c | 127 -------------------------------------- - doc/examples/xz_pipe_decomp.c | 123 ------------------------------------ - doc/examples_old/xz_pipe_comp.c | 127 ++++++++++++++++++++++++++++++++++++++ - doc/examples_old/xz_pipe_decomp.c | 123 ++++++++++++++++++++++++++++++++++++ - 4 files changed, 250 insertions(+), 250 deletions(-) + doc/{examples => examples_old}/xz_pipe_comp.c | 0 + doc/{examples => examples_old}/xz_pipe_decomp.c | 0 + 2 files changed, 0 insertions(+), 0 deletions(-) commit 905f0ab5b5ce544d4b68a2ed6077df0f3d021292 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -4159,10 +4715,9 @@ Date: 2011-04-10 14:58:10 +0300 DOS: Update the docs and include notes about 8.3 filenames. - dos/INSTALL.txt | 79 ++++++++++++++++++++++++++++++++++++ - dos/README | 88 ---------------------------------------- - dos/README.txt | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 202 insertions(+), 88 deletions(-) + dos/{README => INSTALL.txt} | 13 +---- + dos/README.txt | 123 ++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 125 insertions(+), 11 deletions(-) commit ebd54dbd6e481d31e80757f900ac8109ad1423c6 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -4279,10 +4834,9 @@ Date: 2011-04-05 17:12:20 +0300 It was renamed to ax_pthread.m4 in Autoconf Archive. - configure.ac | 2 +- - m4/acx_pthread.m4 | 279 ----------------------------------------------------- - m4/ax_pthread.m4 | 283 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 284 insertions(+), 280 deletions(-) + configure.ac | 2 +- + m4/{acx_pthread.m4 => ax_pthread.m4} | 170 ++++++++++++++++++----------------- + 2 files changed, 88 insertions(+), 84 deletions(-) commit 1039bfcfc098b69d56ecb39d198a092552eacf6d Author: Lasse Collin <lasse.collin@tukaani.org> @@ -4664,10 +5218,10 @@ Date: 2010-11-12 15:22:13 -0600 Builds from a separate build directory with - mkdir build - cd build - ../configure - doxygen Doxyfile + mkdir build + cd build + ../configure + doxygen Doxyfile include an even longer prefix /home/someone/src/xz/src; this patch has the nice side-effect of eliminating that prefix, too. @@ -5232,12 +5786,11 @@ Date: 2010-09-28 10:59:53 +0300 Move version.sh to build-aux. - Makefile.am | 4 ++-- - build-aux/version.sh | 24 ++++++++++++++++++++++++ - configure.ac | 2 +- - version.sh | 24 ------------------------ - windows/build.bash | 2 +- - 5 files changed, 28 insertions(+), 28 deletions(-) + Makefile.am | 4 ++-- + version.sh => build-aux/version.sh | 0 + configure.ac | 2 +- + windows/build.bash | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) commit 84af9d8770451339a692e9b70f96cf56156a6069 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -5739,11 +6292,10 @@ Date: 2010-07-27 20:45:03 +0300 Windows: build.sh is a bash script so name it correctly. - INSTALL | 2 +- - windows/INSTALL-Windows.txt | 6 +- - windows/build.bash | 189 ++++++++++++++++++++++++++++++++++++++++++++ - windows/build.sh | 189 -------------------------------------------- - 4 files changed, 193 insertions(+), 193 deletions(-) + INSTALL | 2 +- + windows/INSTALL-Windows.txt | 6 +++--- + windows/{build.sh => build.bash} | 6 +++--- + 3 files changed, 7 insertions(+), 7 deletions(-) commit b1cbfd40f049a646a639eb78a3e41e9e3ef73339 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -7597,48 +8149,44 @@ Date: 2009-09-19 09:47:30 +0300 building XZ Utils on OpenVMS. Thanks to Jouk Jansen for the original patch. - THANKS | 1 + - configure.ac | 12 ++-- - m4/lc_cpucores.m4 | 57 ---------------- - m4/lc_physmem.m4 | 84 ----------------------- - m4/tuklib_common.m4 | 22 ++++++ - m4/tuklib_cpucores.m4 | 72 ++++++++++++++++++++ - m4/tuklib_physmem.m4 | 119 ++++++++++++++++++++++++++++++++ - m4/tuklib_progname.m4 | 25 +++++++ - src/common/cpucores.h | 51 -------------- - src/common/open_stdxxx.h | 49 -------------- - src/common/physmem.h | 144 --------------------------------------- - src/common/sysdefs.h | 4 -- - src/common/tuklib_common.h | 67 ++++++++++++++++++ - src/common/tuklib_config.h | 1 + - src/common/tuklib_cpucores.c | 46 +++++++++++++ - src/common/tuklib_cpucores.h | 23 +++++++ - src/common/tuklib_exit.c | 57 ++++++++++++++++ - src/common/tuklib_exit.h | 25 +++++++ - src/common/tuklib_gettext.h | 44 ++++++++++++ - src/common/tuklib_open_stdxxx.c | 51 ++++++++++++++ - src/common/tuklib_open_stdxxx.h | 23 +++++++ - src/common/tuklib_physmem.c | 146 ++++++++++++++++++++++++++++++++++++++++ - src/common/tuklib_physmem.h | 28 ++++++++ - src/common/tuklib_progname.c | 50 ++++++++++++++ - src/common/tuklib_progname.h | 32 +++++++++ - src/lzmainfo/Makefile.am | 5 +- - src/lzmainfo/lzmainfo.c | 65 ++++++------------ - src/xz/Makefile.am | 7 +- - src/xz/args.c | 8 +-- - src/xz/file_io.c | 43 ++++++------ - src/xz/hardware.c | 8 +-- - src/xz/main.c | 100 ++++++--------------------- - src/xz/main.h | 7 -- - src/xz/message.c | 30 +++++---- - src/xz/message.h | 8 +-- - src/xz/private.h | 11 +-- - src/xz/signals.c | 2 + - src/xz/signals.h | 17 +++-- - src/xz/suffix.c | 2 +- - src/xzdec/Makefile.am | 13 +++- - src/xzdec/xzdec.c | 55 +++++---------- - 41 files changed, 974 insertions(+), 640 deletions(-) + THANKS | 1 + + configure.ac | 12 +-- + m4/lc_physmem.m4 | 84 --------------- + m4/tuklib_common.m4 | 22 ++++ + m4/{lc_cpucores.m4 => tuklib_cpucores.m4} | 83 ++++++++------ + m4/tuklib_physmem.m4 | 119 +++++++++++++++++++++ + m4/tuklib_progname.m4 | 25 +++++ + src/common/sysdefs.h | 4 - + src/common/tuklib_common.h | 67 ++++++++++++ + src/common/tuklib_config.h | 1 + + src/common/{cpucores.h => tuklib_cpucores.c} | 39 +++---- + src/common/tuklib_cpucores.h | 23 ++++ + src/common/tuklib_exit.c | 57 ++++++++++ + src/common/tuklib_exit.h | 25 +++++ + src/common/tuklib_gettext.h | 44 ++++++++ + src/common/{open_stdxxx.h => tuklib_open_stdxxx.c} | 24 +++-- + src/common/tuklib_open_stdxxx.h | 23 ++++ + src/common/{physmem.h => tuklib_physmem.c} | 58 +++++----- + src/common/tuklib_physmem.h | 28 +++++ + src/common/tuklib_progname.c | 50 +++++++++ + src/common/tuklib_progname.h | 32 ++++++ + src/lzmainfo/Makefile.am | 5 +- + src/lzmainfo/lzmainfo.c | 65 ++++------- + src/xz/Makefile.am | 7 +- + src/xz/args.c | 8 +- + src/xz/file_io.c | 43 ++++---- + src/xz/hardware.c | 8 +- + src/xz/main.c | 100 ++++------------- + src/xz/main.h | 7 -- + src/xz/message.c | 30 +++--- + src/xz/message.h | 8 +- + src/xz/private.h | 11 +- + src/xz/signals.c | 2 + + src/xz/signals.h | 17 ++- + src/xz/suffix.c | 2 +- + src/xzdec/Makefile.am | 13 ++- + src/xzdec/xzdec.c | 55 +++------- + 37 files changed, 768 insertions(+), 434 deletions(-) commit 49cfc8d392cf535f8dd10233225b1fc726fec9ef Author: Lasse Collin <lasse.collin@tukaani.org> @@ -8268,11 +8816,11 @@ Date: 2009-08-09 13:22:12 -0500 It can be somewhat confusing that - less < some_file.txt + less < some_file.txt works fine, whereas - xzless < some_file.txt.xz + xzless < some_file.txt.xz does not. Since version 429, ‘less’ allows a filter specified in the LESSOPEN environment variable to preprocess its input even if @@ -8760,18 +9308,13 @@ Date: 2009-06-27 17:28:01 +0300 Moved the Windows resource files outside the windows directory to prepare for building them with Autotools. - src/common/common_w32res.rc | 46 +++++++++++++++++++++++++++++++++++++++++++ - src/liblzma/liblzma_w32res.rc | 5 +++++ - src/xz/xz_w32res.rc | 5 +++++ - src/xzdec/lzmadec_w32res.rc | 5 +++++ - src/xzdec/xzdec_w32res.rc | 5 +++++ - windows/Makefile | 35 +++++++++++++++++--------------- - windows/common.rc | 46 ------------------------------------------- - windows/liblzma.rc | 5 ----- - windows/lzmadec.rc | 5 ----- - windows/xz.rc | 5 ----- - windows/xzdec.rc | 5 ----- - 11 files changed, 85 insertions(+), 82 deletions(-) + windows/common.rc => src/common/common_w32res.rc | 0 + .../liblzma.rc => src/liblzma/liblzma_w32res.rc | 2 +- + windows/xz.rc => src/xz/xz_w32res.rc | 2 +- + windows/lzmadec.rc => src/xzdec/lzmadec_w32res.rc | 2 +- + windows/xzdec.rc => src/xzdec/xzdec_w32res.rc | 2 +- + windows/Makefile | 35 ++++++++++++---------- + 6 files changed, 23 insertions(+), 20 deletions(-) commit 449c634674f35336a4815d398172e447659a135e Author: Lasse Collin <lasse.collin@tukaani.org> @@ -8853,19 +9396,15 @@ Date: 2009-06-26 20:49:54 +0300 to avoid problems on systems with system headers with those names. - dos/Makefile | 4 +- - src/xz/Makefile.am | 8 +- - src/xz/coder.c | 488 ++++++++++++++++++++++++++++++++++++ - src/xz/coder.h | 57 +++++ - src/xz/file_io.c | 716 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - src/xz/file_io.h | 86 +++++++ - src/xz/io.c | 716 ----------------------------------------------------- - src/xz/io.h | 86 ------- - src/xz/private.h | 4 +- - src/xz/process.c | 488 ------------------------------------ - src/xz/process.h | 57 ----- - windows/Makefile | 4 +- - 12 files changed, 1357 insertions(+), 1357 deletions(-) + dos/Makefile | 4 ++-- + src/xz/Makefile.am | 8 ++++---- + src/xz/{process.c => coder.c} | 0 + src/xz/{process.h => coder.h} | 0 + src/xz/{io.c => file_io.c} | 0 + src/xz/{io.h => file_io.h} | 0 + src/xz/private.h | 4 ++-- + windows/Makefile | 4 ++-- + 8 files changed, 10 insertions(+), 10 deletions(-) commit 5e1257466dcb66f1d7a3f71814a5ad885cba43e8 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -9247,9 +9786,8 @@ Date: 2009-05-01 11:20:23 +0300 Renamed the file format specification to xz-file-format.txt which is the filename used on the WWW. - doc/file-format.txt | 1127 ------------------------------------------------ - doc/xz-file-format.txt | 1127 ++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 1127 insertions(+), 1127 deletions(-) + doc/{file-format.txt => xz-file-format.txt} | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) commit 21c6b94373d239d7e86bd480fcd558e30391712f Author: Lasse Collin <lasse.collin@tukaani.org> @@ -9318,20 +9856,14 @@ Date: 2009-04-13 14:49:48 +0300 Quick & dirty update to support xz in diff/grep/more scripts. - src/scripts/Makefile.am | 38 +++++++++------ - src/scripts/lzdiff | 67 -------------------------- - src/scripts/lzdiff.1 | 51 -------------------- - src/scripts/lzgrep | 123 ------------------------------------------------ - src/scripts/lzgrep.1 | 61 ------------------------ - src/scripts/lzmore | 74 ----------------------------- - src/scripts/lzmore.1 | 55 ---------------------- - src/scripts/xzdiff | 67 ++++++++++++++++++++++++++ - src/scripts/xzdiff.1 | 58 +++++++++++++++++++++++ - src/scripts/xzgrep | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ - src/scripts/xzgrep.1 | 77 ++++++++++++++++++++++++++++++ - src/scripts/xzmore | 74 +++++++++++++++++++++++++++++ - src/scripts/xzmore.1 | 66 ++++++++++++++++++++++++++ - 13 files changed, 489 insertions(+), 445 deletions(-) + src/scripts/Makefile.am | 38 +++++++++++++++++++----------- + src/scripts/{lzdiff => xzdiff} | 24 +++++++++---------- + src/scripts/{lzdiff.1 => xzdiff.1} | 29 ++++++++++++++--------- + src/scripts/{lzgrep => xzgrep} | 10 ++++---- + src/scripts/{lzgrep.1 => xzgrep.1} | 48 +++++++++++++++++++++++++------------- + src/scripts/{lzmore => xzmore} | 12 +++++----- + src/scripts/{lzmore.1 => xzmore.1} | 33 +++++++++++++++++--------- + 7 files changed, 119 insertions(+), 75 deletions(-) commit 02ddf09bc3079b3e17297729b9e43f14d407b8fc Author: Lasse Collin <lasse.collin@tukaani.org> @@ -9675,16 +10207,15 @@ Date: 2009-02-17 10:43:00 +0200 pieces to avoid unneeded dependencies making statically linked applications bigger than needed. - dos/Makefile | 6 +- - src/liblzma/common/easy.c | 128 ----------------------------- - src/liblzma/common/easy_buffer_encoder.c | 34 ++++++++ - src/liblzma/common/easy_decoder_memusage.c | 31 +++++++ - src/liblzma/common/easy_encoder.c | 87 ++++++++++++++++++++ - src/liblzma/common/easy_encoder_memusage.c | 31 +++++++ - src/liblzma/common/easy_preset.c | 34 ++++++++ - src/liblzma/common/easy_preset.h | 39 +++++++++ - windows/Makefile | 6 +- - 9 files changed, 266 insertions(+), 130 deletions(-) + dos/Makefile | 6 ++- + src/liblzma/common/easy_buffer_encoder.c | 34 +++++++++++++++++ + src/liblzma/common/easy_decoder_memusage.c | 31 ++++++++++++++++ + src/liblzma/common/{easy.c => easy_encoder.c} | 53 +++------------------------ + src/liblzma/common/easy_encoder_memusage.c | 31 ++++++++++++++++ + src/liblzma/common/easy_preset.c | 34 +++++++++++++++++ + src/liblzma/common/easy_preset.h | 39 ++++++++++++++++++++ + windows/Makefile | 6 ++- + 8 files changed, 185 insertions(+), 49 deletions(-) commit 7494816ab08d82f4d6409788825930c4e43cfd0d Author: Lasse Collin <lasse.collin@tukaani.org> @@ -10657,15 +11188,14 @@ Date: 2008-12-31 16:29:39 +0200 The internal implementation is still using the name "simple". It may need some cleanups, so I look at it later. - src/liblzma/api/Makefile.am | 2 +- - src/liblzma/api/lzma.h | 2 +- - src/liblzma/api/lzma/bcj.h | 94 +++++++++++++++++++++++++++++++++++++ - src/liblzma/api/lzma/simple.h | 94 ------------------------------------- - src/liblzma/simple/simple_coder.c | 2 +- - src/liblzma/simple/simple_decoder.c | 4 +- - src/liblzma/simple/simple_encoder.c | 4 +- - tests/test_filter_flags.c | 8 ++-- - 8 files changed, 105 insertions(+), 105 deletions(-) + src/liblzma/api/Makefile.am | 2 +- + src/liblzma/api/lzma.h | 2 +- + src/liblzma/api/lzma/{simple.h => bcj.h} | 22 +++++++++++----------- + src/liblzma/simple/simple_coder.c | 2 +- + src/liblzma/simple/simple_decoder.c | 4 ++-- + src/liblzma/simple/simple_encoder.c | 4 ++-- + tests/test_filter_flags.c | 8 ++++---- + 7 files changed, 22 insertions(+), 22 deletions(-) commit 7eea8bec3abfed883efba66264a1452a1c04f6b0 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -10719,47 +11249,44 @@ Date: 2008-12-31 00:30:49 +0200 as the more bloated uint32_t array on x86; hopefully it's not bad on other architectures. - configure.ac | 29 ++++++++-- - src/common/mythread.h | 34 ++++++++++++ - src/liblzma/api/Makefile.am | 1 - - src/liblzma/api/lzma.h | 1 - - src/liblzma/api/lzma/init.h | 85 ----------------------------- - src/liblzma/check/Makefile.am | 29 ++++------ - src/liblzma/check/check.c | 10 ++-- - src/liblzma/check/check.h | 25 ++++----- - src/liblzma/check/check_init.c | 37 ------------- - src/liblzma/check/crc32.c | 88 ------------------------------- - src/liblzma/check/crc32_fast.c | 88 +++++++++++++++++++++++++++++++ - src/liblzma/check/crc32_init.c | 55 ------------------- - src/liblzma/check/crc32_small.c | 54 +++++++++++++++++++ - src/liblzma/check/crc32_tablegen.c | 55 ++++++++++++++++--- - src/liblzma/check/crc64.c | 75 -------------------------- - src/liblzma/check/crc64_fast.c | 75 ++++++++++++++++++++++++++ - src/liblzma/check/crc64_small.c | 54 +++++++++++++++++++ - src/liblzma/check/crc64_tablegen.c | 55 ++++++++++++++++--- - src/liblzma/common/Makefile.am | 3 -- - src/liblzma/common/common.h | 1 + - src/liblzma/common/init.c | 39 -------------- - src/liblzma/common/init_decoder.c | 31 ----------- - src/liblzma/common/init_encoder.c | 40 -------------- - src/liblzma/liblzma.pc.in | 12 +++++ - src/liblzma/lz/lz_encoder.c | 6 +++ - src/liblzma/lzma.pc.in | 11 ---- - src/liblzma/rangecoder/Makefile.am | 8 +-- - src/liblzma/rangecoder/price.h | 16 +----- - src/liblzma/rangecoder/price_table.c | 2 +- - src/liblzma/rangecoder/price_table_init.c | 55 ------------------- - src/liblzma/rangecoder/price_tablegen.c | 51 +++++++++++++++--- - src/xz/Makefile.am | 5 +- - src/xz/main.c | 3 -- - src/xzdec/xzdec.c | 3 -- - tests/test_block_header.c | 1 - - tests/test_check.c | 2 - - tests/test_filter_flags.c | 2 - - tests/test_index.c | 2 - - tests/test_stream_flags.c | 2 - - tests/tests.h | 2 +- - 40 files changed, 519 insertions(+), 628 deletions(-) + configure.ac | 29 ++++++++-- + src/common/mythread.h | 34 ++++++++++++ + src/liblzma/api/Makefile.am | 1 - + src/liblzma/api/lzma.h | 1 - + src/liblzma/api/lzma/init.h | 85 ----------------------------- + src/liblzma/check/Makefile.am | 29 ++++------ + src/liblzma/check/check.c | 10 ++-- + src/liblzma/check/check.h | 25 +++------ + src/liblzma/check/check_init.c | 37 ------------- + src/liblzma/check/{crc32.c => crc32_fast.c} | 0 + src/liblzma/check/crc32_init.c | 55 ------------------- + src/liblzma/check/crc32_small.c | 54 ++++++++++++++++++ + src/liblzma/check/crc32_tablegen.c | 55 ++++++++++++++++--- + src/liblzma/check/{crc64.c => crc64_fast.c} | 0 + src/liblzma/check/crc64_small.c | 54 ++++++++++++++++++ + src/liblzma/check/crc64_tablegen.c | 55 ++++++++++++++++--- + src/liblzma/common/Makefile.am | 3 - + src/liblzma/common/common.h | 1 + + src/liblzma/common/init.c | 39 ------------- + src/liblzma/common/init_decoder.c | 31 ----------- + src/liblzma/common/init_encoder.c | 40 -------------- + src/liblzma/{lzma.pc.in => liblzma.pc.in} | 5 +- + src/liblzma/lz/lz_encoder.c | 6 ++ + src/liblzma/rangecoder/Makefile.am | 8 +-- + src/liblzma/rangecoder/price.h | 16 +----- + src/liblzma/rangecoder/price_table.c | 2 +- + src/liblzma/rangecoder/price_table_init.c | 55 ------------------- + src/liblzma/rangecoder/price_tablegen.c | 51 ++++++++++++++--- + src/xz/Makefile.am | 5 +- + src/xz/main.c | 3 - + src/xzdec/xzdec.c | 3 - + tests/test_block_header.c | 1 - + tests/test_check.c | 2 - + tests/test_filter_flags.c | 2 - + tests/test_index.c | 2 - + tests/test_stream_flags.c | 2 - + tests/tests.h | 2 +- + 37 files changed, 347 insertions(+), 456 deletions(-) commit 5cda29b5665004fc0f21d0c41d78022a6a559ab2 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -11212,58 +11739,35 @@ Date: 2008-11-19 23:52:24 +0200 compatibility with LZMA Utils 4.32.x; I'm not sure if this should be the default though. - configure.ac | 4 +- - po/POTFILES.in | 21 +- - src/Makefile.am | 2 +- - src/lzma/Makefile.am | 72 ---- - src/lzma/args.c | 500 --------------------------- - src/lzma/args.h | 56 --- - src/lzma/hardware.c | 122 ------- - src/lzma/hardware.h | 45 --- - src/lzma/io.c | 658 ----------------------------------- - src/lzma/io.h | 97 ------ - src/lzma/list.c | 477 -------------------------- - src/lzma/main.c | 402 ---------------------- - src/lzma/main.h | 60 ---- - src/lzma/message.c | 892 ------------------------------------------------ - src/lzma/message.h | 132 ------- - src/lzma/options.c | 352 ------------------- - src/lzma/options.h | 46 --- - src/lzma/private.h | 52 --- - src/lzma/process.c | 391 --------------------- - src/lzma/process.h | 70 ---- - src/lzma/suffix.c | 213 ------------ - src/lzma/suffix.h | 40 --- - src/lzma/util.c | 199 ----------- - src/lzma/util.h | 71 ---- - src/lzmadec/Makefile.am | 29 -- - src/lzmadec/lzmadec.c | 492 -------------------------- - src/xz/Makefile.am | 74 ++++ - src/xz/args.c | 500 +++++++++++++++++++++++++++ - src/xz/args.h | 56 +++ - src/xz/hardware.c | 122 +++++++ - src/xz/hardware.h | 45 +++ - src/xz/io.c | 658 +++++++++++++++++++++++++++++++++++ - src/xz/io.h | 97 ++++++ - src/xz/list.c | 477 ++++++++++++++++++++++++++ - src/xz/main.c | 402 ++++++++++++++++++++++ - src/xz/main.h | 60 ++++ - src/xz/message.c | 892 ++++++++++++++++++++++++++++++++++++++++++++++++ - src/xz/message.h | 132 +++++++ - src/xz/options.c | 352 +++++++++++++++++++ - src/xz/options.h | 46 +++ - src/xz/private.h | 52 +++ - src/xz/process.c | 391 +++++++++++++++++++++ - src/xz/process.h | 70 ++++ - src/xz/suffix.c | 213 ++++++++++++ - src/xz/suffix.h | 40 +++ - src/xz/util.c | 199 +++++++++++ - src/xz/util.h | 71 ++++ - src/xzdec/Makefile.am | 29 ++ - src/xzdec/xzdec.c | 492 ++++++++++++++++++++++++++ - tests/test_compress.sh | 29 +- - tests/test_files.sh | 4 +- - 51 files changed, 5498 insertions(+), 5500 deletions(-) + configure.ac | 4 ++-- + po/POTFILES.in | 21 +++++++++------------ + src/Makefile.am | 2 +- + src/{lzma => xz}/Makefile.am | 32 +++++++++++++++++--------------- + src/{lzma => xz}/args.c | 0 + src/{lzma => xz}/args.h | 0 + src/{lzma => xz}/hardware.c | 0 + src/{lzma => xz}/hardware.h | 0 + src/{lzma => xz}/io.c | 0 + src/{lzma => xz}/io.h | 0 + src/{lzma => xz}/list.c | 0 + src/{lzma => xz}/main.c | 0 + src/{lzma => xz}/main.h | 0 + src/{lzma => xz}/message.c | 0 + src/{lzma => xz}/message.h | 0 + src/{lzma => xz}/options.c | 0 + src/{lzma => xz}/options.h | 0 + src/{lzma => xz}/private.h | 0 + src/{lzma => xz}/process.c | 0 + src/{lzma => xz}/process.h | 0 + src/{lzma => xz}/suffix.c | 0 + src/{lzma => xz}/suffix.h | 0 + src/{lzma => xz}/util.c | 0 + src/{lzma => xz}/util.h | 0 + src/{lzmadec => xzdec}/Makefile.am | 12 ++++++------ + src/{lzmadec/lzmadec.c => xzdec/xzdec.c} | 4 ++-- + tests/test_compress.sh | 29 ++++++++++++++--------------- + tests/test_files.sh | 4 ++-- + 28 files changed, 53 insertions(+), 55 deletions(-) commit e114502b2bc371e4a45449832cb69be036360722 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -11289,9 +11793,8 @@ Date: 2008-11-19 20:46:52 +0200 doc/file-format.txt | 260 ++++---- lib/Makefile.am | 10 +- lib/getopt.c | 14 +- - lib/getopt.in.h | 226 +++++++ + lib/{getopt_.h => getopt.in.h} | 8 +- lib/getopt1.c | 8 +- - lib/getopt_.h | 226 ------- lib/gettext.h | 240 ------- m4/getopt.m4 | 64 +- src/common/bswap.h | 15 +- @@ -11393,7 +11896,7 @@ Date: 2008-11-19 20:46:52 +0200 tests/files/unsupported-filter_flags-3.xz | Bin 68 -> 68 bytes tests/test_block_header.c | 16 +- tests/test_index.c | 42 +- - 113 files changed, 3462 insertions(+), 2946 deletions(-) + 112 files changed, 3240 insertions(+), 2724 deletions(-) commit 3c3905b53462ae235c9438d86a4dc51086410932 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -11467,123 +11970,66 @@ Date: 2008-09-30 17:43:55 +0300 Renamed the test files from .lzma suffix to .xz suffix. - tests/files/README | 128 ++++++++++++------------- - tests/files/bad-0-backward_size.lzma | Bin 32 -> 0 bytes - tests/files/bad-0-backward_size.xz | Bin 0 -> 32 bytes - tests/files/bad-0-empty-truncated.lzma | Bin 31 -> 0 bytes - tests/files/bad-0-empty-truncated.xz | Bin 0 -> 31 bytes - tests/files/bad-0-footer_magic.lzma | Bin 32 -> 0 bytes - tests/files/bad-0-footer_magic.xz | Bin 0 -> 32 bytes - tests/files/bad-0-header_magic.lzma | Bin 32 -> 0 bytes - tests/files/bad-0-header_magic.xz | Bin 0 -> 32 bytes - tests/files/bad-0-nonempty_index.lzma | Bin 32 -> 0 bytes - tests/files/bad-0-nonempty_index.xz | Bin 0 -> 32 bytes - tests/files/bad-0cat-alone.lzma | Bin 55 -> 0 bytes - tests/files/bad-0cat-alone.xz | Bin 0 -> 55 bytes - tests/files/bad-0cat-header_magic.lzma | Bin 64 -> 0 bytes - tests/files/bad-0cat-header_magic.xz | Bin 0 -> 64 bytes - tests/files/bad-0catpad-empty.lzma | Bin 69 -> 0 bytes - tests/files/bad-0catpad-empty.xz | Bin 0 -> 69 bytes - tests/files/bad-0pad-empty.lzma | Bin 37 -> 0 bytes - tests/files/bad-0pad-empty.xz | Bin 0 -> 37 bytes - tests/files/bad-1-block_header-1.lzma | Bin 64 -> 0 bytes - tests/files/bad-1-block_header-1.xz | Bin 0 -> 64 bytes - tests/files/bad-1-block_header-2.lzma | Bin 64 -> 0 bytes - tests/files/bad-1-block_header-2.xz | Bin 0 -> 64 bytes - tests/files/bad-1-block_header-3.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-block_header-3.xz | Bin 0 -> 68 bytes - tests/files/bad-1-block_header-4.lzma | Bin 72 -> 0 bytes - tests/files/bad-1-block_header-4.xz | Bin 0 -> 72 bytes - tests/files/bad-1-check-crc32.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-check-crc32.xz | Bin 0 -> 68 bytes - tests/files/bad-1-check-crc64.lzma | Bin 72 -> 0 bytes - tests/files/bad-1-check-crc64.xz | Bin 0 -> 72 bytes - tests/files/bad-1-check-sha256.lzma | Bin 96 -> 0 bytes - tests/files/bad-1-check-sha256.xz | Bin 0 -> 96 bytes - tests/files/bad-1-lzma2-1.lzma | Bin 64 -> 0 bytes - tests/files/bad-1-lzma2-1.xz | Bin 0 -> 64 bytes - tests/files/bad-1-lzma2-2.lzma | Bin 424 -> 0 bytes - tests/files/bad-1-lzma2-2.xz | Bin 0 -> 424 bytes - tests/files/bad-1-lzma2-3.lzma | Bin 424 -> 0 bytes - tests/files/bad-1-lzma2-3.xz | Bin 0 -> 424 bytes - tests/files/bad-1-lzma2-4.lzma | Bin 408 -> 0 bytes - tests/files/bad-1-lzma2-4.xz | Bin 0 -> 408 bytes - tests/files/bad-1-lzma2-5.lzma | Bin 408 -> 0 bytes - tests/files/bad-1-lzma2-5.xz | Bin 0 -> 408 bytes - tests/files/bad-1-lzma2-6.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-lzma2-6.xz | Bin 0 -> 68 bytes - tests/files/bad-1-lzma2-7.lzma | Bin 408 -> 0 bytes - tests/files/bad-1-lzma2-7.xz | Bin 0 -> 408 bytes - tests/files/bad-1-stream_flags-1.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-stream_flags-1.xz | Bin 0 -> 68 bytes - tests/files/bad-1-stream_flags-2.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-stream_flags-2.xz | Bin 0 -> 68 bytes - tests/files/bad-1-stream_flags-3.lzma | Bin 68 -> 0 bytes - tests/files/bad-1-stream_flags-3.xz | Bin 0 -> 68 bytes - tests/files/bad-1-vli-1.lzma | Bin 72 -> 0 bytes - tests/files/bad-1-vli-1.xz | Bin 0 -> 72 bytes - tests/files/bad-1-vli-2.lzma | Bin 72 -> 0 bytes - tests/files/bad-1-vli-2.xz | Bin 0 -> 72 bytes - tests/files/bad-2-compressed_data_padding.lzma | Bin 92 -> 0 bytes - tests/files/bad-2-compressed_data_padding.xz | Bin 0 -> 92 bytes - tests/files/bad-2-index-1.lzma | Bin 92 -> 0 bytes - tests/files/bad-2-index-1.xz | Bin 0 -> 92 bytes - tests/files/bad-2-index-2.lzma | Bin 92 -> 0 bytes - tests/files/bad-2-index-2.xz | Bin 0 -> 92 bytes - tests/files/bad-2-index-3.lzma | Bin 92 -> 0 bytes - tests/files/bad-2-index-3.xz | Bin 0 -> 92 bytes - tests/files/bad-2-index-4.lzma | Bin 92 -> 0 bytes - tests/files/bad-2-index-4.xz | Bin 0 -> 92 bytes - tests/files/good-0-empty.lzma | Bin 32 -> 0 bytes - tests/files/good-0-empty.xz | Bin 0 -> 32 bytes - tests/files/good-0cat-empty.lzma | Bin 64 -> 0 bytes - tests/files/good-0cat-empty.xz | Bin 0 -> 64 bytes - tests/files/good-0catpad-empty.lzma | Bin 68 -> 0 bytes - tests/files/good-0catpad-empty.xz | Bin 0 -> 68 bytes - tests/files/good-0pad-empty.lzma | Bin 36 -> 0 bytes - tests/files/good-0pad-empty.xz | Bin 0 -> 36 bytes - tests/files/good-1-3delta-lzma2.lzma | Bin 528 -> 0 bytes - tests/files/good-1-3delta-lzma2.xz | Bin 0 -> 528 bytes - tests/files/good-1-block_header-1.lzma | Bin 72 -> 0 bytes - tests/files/good-1-block_header-1.xz | Bin 0 -> 72 bytes - tests/files/good-1-block_header-2.lzma | Bin 68 -> 0 bytes - tests/files/good-1-block_header-2.xz | Bin 0 -> 68 bytes - tests/files/good-1-block_header-3.lzma | Bin 68 -> 0 bytes - tests/files/good-1-block_header-3.xz | Bin 0 -> 68 bytes - tests/files/good-1-check-crc32.lzma | Bin 68 -> 0 bytes - tests/files/good-1-check-crc32.xz | Bin 0 -> 68 bytes - tests/files/good-1-check-crc64.lzma | Bin 72 -> 0 bytes - tests/files/good-1-check-crc64.xz | Bin 0 -> 72 bytes - tests/files/good-1-check-none.lzma | Bin 64 -> 0 bytes - tests/files/good-1-check-none.xz | Bin 0 -> 64 bytes - tests/files/good-1-check-sha256.lzma | Bin 96 -> 0 bytes - tests/files/good-1-check-sha256.xz | Bin 0 -> 96 bytes - tests/files/good-1-delta-lzma2.tiff.lzma | Bin 51312 -> 0 bytes - tests/files/good-1-delta-lzma2.tiff.xz | Bin 0 -> 51312 bytes - tests/files/good-1-lzma2-1.lzma | Bin 424 -> 0 bytes - tests/files/good-1-lzma2-1.xz | Bin 0 -> 424 bytes - tests/files/good-1-lzma2-2.lzma | Bin 424 -> 0 bytes - tests/files/good-1-lzma2-2.xz | Bin 0 -> 424 bytes - tests/files/good-1-lzma2-3.lzma | Bin 408 -> 0 bytes - tests/files/good-1-lzma2-3.xz | Bin 0 -> 408 bytes - tests/files/good-1-sparc-lzma2.lzma | Bin 2292 -> 0 bytes - tests/files/good-1-sparc-lzma2.xz | Bin 0 -> 2292 bytes - tests/files/good-1-x86-lzma2.lzma | Bin 1936 -> 0 bytes - tests/files/good-1-x86-lzma2.xz | Bin 0 -> 1936 bytes - tests/files/good-2-lzma2.lzma | Bin 92 -> 0 bytes - tests/files/good-2-lzma2.xz | Bin 0 -> 92 bytes - tests/files/unsupported-block_header.lzma | Bin 68 -> 0 bytes - tests/files/unsupported-block_header.xz | Bin 0 -> 68 bytes - tests/files/unsupported-check.lzma | Bin 68 -> 0 bytes - tests/files/unsupported-check.xz | Bin 0 -> 68 bytes - tests/files/unsupported-filter_flags-1.lzma | Bin 68 -> 0 bytes - tests/files/unsupported-filter_flags-1.xz | Bin 0 -> 68 bytes - tests/files/unsupported-filter_flags-2.lzma | Bin 68 -> 0 bytes - tests/files/unsupported-filter_flags-2.xz | Bin 0 -> 68 bytes - tests/files/unsupported-filter_flags-3.lzma | Bin 68 -> 0 bytes - tests/files/unsupported-filter_flags-3.xz | Bin 0 -> 68 bytes - tests/test_files.sh | 6 +- - 116 files changed, 66 insertions(+), 68 deletions(-) + tests/files/README | 128 ++++++++++----------- + ...0-backward_size.lzma => bad-0-backward_size.xz} | Bin + ...pty-truncated.lzma => bad-0-empty-truncated.xz} | Bin + ...d-0-footer_magic.lzma => bad-0-footer_magic.xz} | Bin + ...d-0-header_magic.lzma => bad-0-header_magic.xz} | Bin + ...nonempty_index.lzma => bad-0-nonempty_index.xz} | Bin + .../{bad-0cat-alone.lzma => bad-0cat-alone.xz} | Bin + ...-header_magic.lzma => bad-0cat-header_magic.xz} | Bin + ...bad-0catpad-empty.lzma => bad-0catpad-empty.xz} | Bin + .../{bad-0pad-empty.lzma => bad-0pad-empty.xz} | Bin + ...block_header-1.lzma => bad-1-block_header-1.xz} | Bin + ...block_header-2.lzma => bad-1-block_header-2.xz} | Bin + ...block_header-3.lzma => bad-1-block_header-3.xz} | Bin + ...block_header-4.lzma => bad-1-block_header-4.xz} | Bin + ...bad-1-check-crc32.lzma => bad-1-check-crc32.xz} | Bin + ...bad-1-check-crc64.lzma => bad-1-check-crc64.xz} | Bin + ...d-1-check-sha256.lzma => bad-1-check-sha256.xz} | Bin + .../files/{bad-1-lzma2-1.lzma => bad-1-lzma2-1.xz} | Bin + .../files/{bad-1-lzma2-2.lzma => bad-1-lzma2-2.xz} | Bin + .../files/{bad-1-lzma2-3.lzma => bad-1-lzma2-3.xz} | Bin + .../files/{bad-1-lzma2-4.lzma => bad-1-lzma2-4.xz} | Bin + .../files/{bad-1-lzma2-5.lzma => bad-1-lzma2-5.xz} | Bin + .../files/{bad-1-lzma2-6.lzma => bad-1-lzma2-6.xz} | Bin + .../files/{bad-1-lzma2-7.lzma => bad-1-lzma2-7.xz} | Bin + ...stream_flags-1.lzma => bad-1-stream_flags-1.xz} | Bin + ...stream_flags-2.lzma => bad-1-stream_flags-2.xz} | Bin + ...stream_flags-3.lzma => bad-1-stream_flags-3.xz} | Bin + tests/files/{bad-1-vli-1.lzma => bad-1-vli-1.xz} | Bin + tests/files/{bad-1-vli-2.lzma => bad-1-vli-2.xz} | Bin + ...dding.lzma => bad-2-compressed_data_padding.xz} | Bin + .../files/{bad-2-index-1.lzma => bad-2-index-1.xz} | Bin + .../files/{bad-2-index-2.lzma => bad-2-index-2.xz} | Bin + .../files/{bad-2-index-3.lzma => bad-2-index-3.xz} | Bin + .../files/{bad-2-index-4.lzma => bad-2-index-4.xz} | Bin + tests/files/{good-0-empty.lzma => good-0-empty.xz} | Bin + .../{good-0cat-empty.lzma => good-0cat-empty.xz} | Bin + ...od-0catpad-empty.lzma => good-0catpad-empty.xz} | Bin + .../{good-0pad-empty.lzma => good-0pad-empty.xz} | Bin + ...-1-3delta-lzma2.lzma => good-1-3delta-lzma2.xz} | Bin + ...lock_header-1.lzma => good-1-block_header-1.xz} | Bin + ...lock_header-2.lzma => good-1-block_header-2.xz} | Bin + ...lock_header-3.lzma => good-1-block_header-3.xz} | Bin + ...od-1-check-crc32.lzma => good-1-check-crc32.xz} | Bin + ...od-1-check-crc64.lzma => good-1-check-crc64.xz} | Bin + ...good-1-check-none.lzma => good-1-check-none.xz} | Bin + ...-1-check-sha256.lzma => good-1-check-sha256.xz} | Bin + ...-lzma2.tiff.lzma => good-1-delta-lzma2.tiff.xz} | Bin + .../{good-1-lzma2-1.lzma => good-1-lzma2-1.xz} | Bin + .../{good-1-lzma2-2.lzma => good-1-lzma2-2.xz} | Bin + .../{good-1-lzma2-3.lzma => good-1-lzma2-3.xz} | Bin + ...od-1-sparc-lzma2.lzma => good-1-sparc-lzma2.xz} | Bin + .../{good-1-x86-lzma2.lzma => good-1-x86-lzma2.xz} | Bin + tests/files/{good-2-lzma2.lzma => good-2-lzma2.xz} | Bin + ...ock_header.lzma => unsupported-block_header.xz} | Bin + ...unsupported-check.lzma => unsupported-check.xz} | Bin + ..._flags-1.lzma => unsupported-filter_flags-1.xz} | Bin + ..._flags-2.lzma => unsupported-filter_flags-2.xz} | Bin + ..._flags-3.lzma => unsupported-filter_flags-3.xz} | Bin + tests/test_files.sh | 6 +- + 59 files changed, 66 insertions(+), 68 deletions(-) commit 8e60c889a2816a63013a35c99ce26bf28f5b78eb Author: Lasse Collin <lasse.collin@tukaani.org> @@ -12174,7 +12620,7 @@ Date: 2008-08-28 22:53:15 +0300 configure.ac | 356 +++--- debug/Makefile.am | 5 +- - debug/crc32.c | 45 + + .../lz/lz_encoder_private.h => debug/crc32.c | 41 +- debug/full_flush.c | 14 +- debug/hex2bin.c | 54 + debug/known_sizes.c | 135 ++ @@ -12223,15 +12669,8 @@ Date: 2008-08-28 22:53:15 +0300 src/liblzma/common/block_header_decoder.c | 6 +- src/liblzma/common/block_header_encoder.c | 9 +- src/liblzma/common/block_util.c | 10 +- - src/liblzma/common/code.c | 203 --- - src/liblzma/common/common.c | 298 +++++ + src/liblzma/common/{code.c => common.c} | 129 +- src/liblzma/common/common.h | 237 ++-- - src/liblzma/common/delta_common.c | 66 - - src/liblzma/common/delta_common.h | 44 - - src/liblzma/common/delta_decoder.c | 61 - - src/liblzma/common/delta_decoder.h | 28 - - src/liblzma/common/delta_encoder.c | 98 -- - src/liblzma/common/delta_encoder.h | 28 - src/liblzma/common/easy.c | 18 +- src/liblzma/common/features.c | 66 - src/liblzma/common/filter_common.c | 262 ++++ @@ -12249,33 +12688,27 @@ Date: 2008-08-28 22:53:15 +0300 src/liblzma/common/memory_usage.c | 112 -- src/liblzma/common/next_coder.c | 65 - src/liblzma/common/raw_common.c | 127 -- - src/liblzma/common/raw_common.h | 30 - src/liblzma/common/raw_decoder.c | 116 -- - src/liblzma/common/raw_decoder.h | 29 - src/liblzma/common/raw_encoder.c | 111 -- - src/liblzma/common/raw_encoder.h | 29 - src/liblzma/common/stream_common.c | 23 - - src/liblzma/common/stream_common.h | 31 - src/liblzma/common/stream_decoder.c | 238 +++- src/liblzma/common/stream_decoder.h | 4 +- src/liblzma/common/stream_encoder.c | 35 +- src/liblzma/common/stream_encoder.h | 2 +- - src/liblzma/common/stream_flags_common.c | 40 + - src/liblzma/common/stream_flags_common.h | 31 + + ...{stream_flags_equal.c => stream_flags_common.c} | 14 +- + .../{stream_common.h => stream_flags_common.h} | 8 +- src/liblzma/common/stream_flags_decoder.c | 2 +- src/liblzma/common/stream_flags_encoder.c | 2 +- - src/liblzma/common/stream_flags_equal.c | 36 - - src/liblzma/common/version.c | 25 - src/liblzma/common/vli_decoder.c | 29 +- src/liblzma/common/vli_encoder.c | 23 +- - src/liblzma/common/vli_size.c | 37 + + src/liblzma/common/{version.c => vli_size.c} | 22 +- src/liblzma/delta/Makefile.am | 34 + - src/liblzma/delta/delta_common.c | 66 + - src/liblzma/delta/delta_common.h | 44 + - src/liblzma/delta/delta_decoder.c | 82 ++ - src/liblzma/delta/delta_decoder.h | 32 + - src/liblzma/delta/delta_encoder.c | 119 ++ - src/liblzma/delta/delta_encoder.h | 30 + + src/liblzma/{common => delta}/delta_common.c | 2 +- + src/liblzma/{common => delta}/delta_common.h | 0 + src/liblzma/{common => delta}/delta_decoder.c | 21 + + src/liblzma/{common => delta}/delta_decoder.h | 4 + + src/liblzma/{common => delta}/delta_encoder.c | 21 + + src/liblzma/{common => delta}/delta_encoder.h | 2 + src/liblzma/lz/Makefile.am | 35 +- src/liblzma/lz/bt2.c | 27 - src/liblzma/lz/bt2.h | 31 - @@ -12293,7 +12726,6 @@ Date: 2008-08-28 22:53:15 +0300 src/liblzma/lz/lz_encoder.h | 334 +++-- src/liblzma/lz/lz_encoder_hash.h | 104 ++ src/liblzma/lz/lz_encoder_mf.c | 780 ++++++++++++ - src/liblzma/lz/lz_encoder_private.h | 40 - src/liblzma/lz/match_c.h | 412 ------ src/liblzma/lz/match_h.h | 69 -- src/liblzma/lzma/Makefile.am | 37 +- @@ -12301,7 +12733,7 @@ Date: 2008-08-28 22:53:15 +0300 src/liblzma/lzma/lzma2_decoder.c | 318 +++++ src/liblzma/lzma/lzma2_decoder.h | 35 + src/liblzma/lzma/lzma2_encoder.c | 406 ++++++ - src/liblzma/lzma/lzma2_encoder.h | 34 + + .../{common/raw_common.h => lzma/lzma2_encoder.h} | 22 +- src/liblzma/lzma/lzma_common.h | 208 +++- src/liblzma/lzma/lzma_decoder.c | 1306 ++++++++++++-------- src/liblzma/lzma/lzma_decoder.h | 21 +- @@ -12320,18 +12752,17 @@ Date: 2008-08-28 22:53:15 +0300 src/liblzma/rangecoder/Makefile.am | 10 +- src/liblzma/rangecoder/price.h | 111 ++ src/liblzma/rangecoder/price_table.c | 84 +- - src/liblzma/rangecoder/price_table_gen.c | 55 - src/liblzma/rangecoder/price_table_init.c | 33 +- - src/liblzma/rangecoder/price_tablegen.c | 56 + + .../{price_table_gen.c => price_tablegen.c} | 19 +- src/liblzma/rangecoder/range_common.h | 17 +- src/liblzma/rangecoder/range_decoder.h | 209 ++-- src/liblzma/rangecoder/range_encoder.h | 92 +- src/liblzma/simple/Makefile.am | 12 + src/liblzma/simple/simple_coder.c | 8 +- src/liblzma/simple/simple_decoder.c | 47 + - src/liblzma/simple/simple_decoder.h | 29 + + .../raw_decoder.h => simple/simple_decoder.h} | 18 +- src/liblzma/simple/simple_encoder.c | 45 + - src/liblzma/simple/simple_encoder.h | 30 + + .../raw_encoder.h => simple/simple_encoder.h} | 17 +- src/liblzma/subblock/Makefile.am | 4 +- src/liblzma/subblock/subblock_decoder.c | 20 +- src/liblzma/subblock/subblock_decoder_helper.c | 2 +- @@ -12423,8 +12854,8 @@ Date: 2008-08-28 22:53:15 +0300 tests/files/good-1-lzma2-1.lzma | Bin 0 -> 424 bytes tests/files/good-1-lzma2-2.lzma | Bin 0 -> 424 bytes tests/files/good-1-lzma2-3.lzma | Bin 0 -> 408 bytes - tests/files/good-1-sparc-lzma2.lzma | Bin 0 -> 2292 bytes - tests/files/good-1-x86-lzma2.lzma | Bin 0 -> 1936 bytes + ...gle-sparc-lzma.lzma => good-1-sparc-lzma2.lzma} | Bin 2263 -> 2292 bytes + ...-single-x86-lzma.lzma => good-1-x86-lzma2.lzma} | Bin 1909 -> 1936 bytes tests/files/good-2-lzma2.lzma | Bin 0 -> 92 bytes tests/files/good-cat-single-none-pad.lzma | Bin 64 -> 0 bytes tests/files/good-multi-none-1.lzma | Bin 75 -> 0 bytes @@ -12447,11 +12878,9 @@ Date: 2008-08-28 22:53:15 +0300 tests/files/good-single-none-empty_3.lzma | Bin 19 -> 0 bytes tests/files/good-single-none-pad.lzma | Bin 32 -> 0 bytes tests/files/good-single-none.lzma | Bin 30 -> 0 bytes - tests/files/good-single-sparc-lzma.lzma | Bin 2263 -> 0 bytes tests/files/good-single-subblock-lzma.lzma | Bin 50 -> 0 bytes tests/files/good-single-subblock_implicit.lzma | Bin 35 -> 0 bytes tests/files/good-single-subblock_rle.lzma | Bin 118 -> 0 bytes - tests/files/good-single-x86-lzma.lzma | Bin 1909 -> 0 bytes tests/files/malicious-multi-metadata-64PiB.lzma | Bin 51 -> 0 bytes tests/files/malicious-single-subblock-256MiB.lzma | Bin 30 -> 0 bytes tests/files/malicious-single-subblock-64PiB.lzma | Bin 45 -> 0 bytes @@ -12466,7 +12895,7 @@ Date: 2008-08-28 22:53:15 +0300 tests/test_filter_flags.c | 51 +- tests/test_stream_flags.c | 4 +- tests/tests.h | 8 + - 294 files changed, 9768 insertions(+), 8195 deletions(-) + 277 files changed, 9050 insertions(+), 7477 deletions(-) commit 57b9a145a527f0716822615e5ed536d33aebd3fc Author: Lasse Collin <lasse.collin@tukaani.org> @@ -12542,122 +12971,116 @@ Date: 2008-06-18 18:02:10 +0300 updated once the encoded format of the Subblock filter has been decided. - configure.ac | 41 +- - debug/full_flush.c | 16 +- - debug/sync_flush.c | 15 +- - src/common/bswap.h | 44 ++ - src/common/integer.h | 167 +++++ - src/liblzma/api/Makefile.am | 5 +- - src/liblzma/api/lzma.h | 9 +- - src/liblzma/api/lzma/alone.h | 32 +- - src/liblzma/api/lzma/auto.h | 7 +- - src/liblzma/api/lzma/base.h | 15 + - src/liblzma/api/lzma/block.h | 306 +++------- - src/liblzma/api/lzma/check.h | 18 +- - src/liblzma/api/lzma/copy.h | 29 - - src/liblzma/api/lzma/easy.h | 61 +- - src/liblzma/api/lzma/extra.h | 114 ---- - src/liblzma/api/lzma/filter.h | 5 +- - src/liblzma/api/lzma/index.h | 204 ++++++- - src/liblzma/api/lzma/index_hash.h | 94 +++ - src/liblzma/api/lzma/info.h | 315 ---------- - src/liblzma/api/lzma/lzma.h | 2 +- - src/liblzma/api/lzma/metadata.h | 100 --- - src/liblzma/api/lzma/raw.h | 20 +- - src/liblzma/api/lzma/stream.h | 157 +---- - src/liblzma/api/lzma/stream_flags.h | 146 +++-- - src/liblzma/api/lzma/version.h | 2 +- - src/liblzma/api/lzma/vli.h | 83 ++- - src/liblzma/check/Makefile.am | 1 - - src/liblzma/check/check.c | 55 +- - src/liblzma/check/check.h | 47 +- - src/liblzma/check/check_byteswap.h | 43 -- - src/liblzma/check/crc32_init.c | 2 +- - src/liblzma/check/crc64_init.c | 2 +- - src/liblzma/check/crc_macros.h | 2 +- - src/liblzma/check/sha256.c | 53 +- - src/liblzma/common/Makefile.am | 31 +- - src/liblzma/common/alignment.c | 5 +- - src/liblzma/common/alone_decoder.c | 77 +-- - src/liblzma/common/alone_encoder.c | 99 ++- - src/liblzma/common/auto_decoder.c | 18 +- - src/liblzma/common/block_decoder.c | 298 +++------ - src/liblzma/common/block_encoder.c | 228 ++----- - src/liblzma/common/block_header_decoder.c | 400 +++--------- - src/liblzma/common/block_header_encoder.c | 207 +++---- - src/liblzma/common/block_private.h | 51 +- - src/liblzma/common/block_util.c | 73 +++ - src/liblzma/common/common.h | 44 +- - src/liblzma/common/copy_coder.c | 144 ----- - src/liblzma/common/copy_coder.h | 31 - - src/liblzma/common/delta_common.c | 4 - - src/liblzma/common/delta_common.h | 4 - - src/liblzma/common/delta_decoder.c | 55 +- - src/liblzma/common/delta_encoder.c | 7 +- - src/liblzma/common/easy.c | 122 ++++ - src/liblzma/common/easy_common.c | 54 -- - src/liblzma/common/easy_common.h | 28 - - src/liblzma/common/easy_multi.c | 103 ---- - src/liblzma/common/easy_single.c | 37 -- - src/liblzma/common/extra.c | 34 -- - src/liblzma/common/features.c | 4 - - src/liblzma/common/filter_flags_decoder.c | 384 ++++-------- - src/liblzma/common/filter_flags_encoder.c | 120 +--- - src/liblzma/common/index.c | 773 ++++++++++++++++++++--- - src/liblzma/common/index.h | 67 ++ - src/liblzma/common/index_decoder.c | 252 ++++++++ - src/liblzma/common/index_encoder.c | 222 +++++++ - src/liblzma/common/index_encoder.h | 30 + - src/liblzma/common/index_hash.c | 340 +++++++++++ - src/liblzma/common/info.c | 814 ------------------------- - src/liblzma/common/memory_usage.c | 1 - - src/liblzma/common/metadata_decoder.c | 578 ------------------ - src/liblzma/common/metadata_decoder.h | 31 - - src/liblzma/common/metadata_encoder.c | 435 ------------- - src/liblzma/common/metadata_encoder.h | 30 - - src/liblzma/common/raw_common.c | 178 ++---- - src/liblzma/common/raw_common.h | 5 +- - src/liblzma/common/raw_decoder.c | 19 +- - src/liblzma/common/raw_decoder.h | 3 +- - src/liblzma/common/raw_encoder.c | 101 +-- - src/liblzma/common/raw_encoder.h | 3 +- - src/liblzma/common/stream_common.h | 3 + - src/liblzma/common/stream_decoder.c | 458 +++++--------- - src/liblzma/common/stream_decoder.h | 28 + - src/liblzma/common/stream_encoder.c | 282 +++++++++ - src/liblzma/common/stream_encoder.h | 30 + - src/liblzma/common/stream_encoder_multi.c | 445 -------------- - src/liblzma/common/stream_encoder_multi.h | 26 - - src/liblzma/common/stream_encoder_single.c | 219 ------- - src/liblzma/common/stream_flags_decoder.c | 260 ++------ - src/liblzma/common/stream_flags_encoder.c | 56 +- - src/liblzma/common/stream_flags_equal.c | 36 ++ - src/liblzma/common/vli_decoder.c | 68 ++- - src/liblzma/common/vli_encoder.c | 59 +- - src/liblzma/common/vli_reverse_decoder.c | 55 -- - src/liblzma/lz/lz_decoder.c | 6 +- - src/liblzma/lz/lz_decoder.h | 10 +- - src/liblzma/lzma/lzma_decoder.c | 13 +- - src/liblzma/lzma/lzma_decoder.h | 10 +- - src/liblzma/simple/simple_coder.c | 29 +- - src/liblzma/simple/simple_private.h | 4 - - src/liblzma/subblock/subblock_decoder.c | 106 +--- - src/liblzma/subblock/subblock_decoder_helper.c | 5 +- - src/liblzma/subblock/subblock_encoder.c | 8 +- - src/lzma/args.c | 22 +- - src/lzma/args.h | 2 - - src/lzma/error.c | 6 + - src/lzma/process.c | 26 +- - src/lzmadec/lzmadec.c | 8 +- - tests/Makefile.am | 5 +- - tests/test_block_header.c | 411 +++++-------- - tests/test_compress.sh | 65 +- - tests/test_filter_flags.c | 116 ++-- - tests/test_index.c | 504 ++++++++++++++- - tests/test_info.c | 717 ---------------------- - tests/test_stream_flags.c | 134 ++-- - tests/tests.h | 14 +- - 115 files changed, 4846 insertions(+), 8156 deletions(-) + configure.ac | 41 +- + debug/full_flush.c | 16 +- + debug/sync_flush.c | 15 +- + .../check/check_byteswap.h => common/bswap.h} | 15 +- + src/common/integer.h | 167 +++++ + src/liblzma/api/Makefile.am | 5 +- + src/liblzma/api/lzma.h | 9 +- + src/liblzma/api/lzma/alone.h | 32 +- + src/liblzma/api/lzma/auto.h | 7 +- + src/liblzma/api/lzma/base.h | 15 + + src/liblzma/api/lzma/block.h | 306 +++----- + src/liblzma/api/lzma/check.h | 18 +- + src/liblzma/api/lzma/copy.h | 29 - + src/liblzma/api/lzma/easy.h | 61 +- + src/liblzma/api/lzma/extra.h | 114 --- + src/liblzma/api/lzma/filter.h | 5 +- + src/liblzma/api/lzma/index.h | 204 +++++- + src/liblzma/api/lzma/index_hash.h | 94 +++ + src/liblzma/api/lzma/info.h | 315 -------- + src/liblzma/api/lzma/lzma.h | 2 +- + src/liblzma/api/lzma/metadata.h | 100 --- + src/liblzma/api/lzma/raw.h | 20 +- + src/liblzma/api/lzma/stream.h | 157 +--- + src/liblzma/api/lzma/stream_flags.h | 146 ++-- + src/liblzma/api/lzma/version.h | 2 +- + src/liblzma/api/lzma/vli.h | 83 +-- + src/liblzma/check/Makefile.am | 1 - + src/liblzma/check/check.c | 55 +- + src/liblzma/check/check.h | 47 +- + src/liblzma/check/crc32_init.c | 2 +- + src/liblzma/check/crc64_init.c | 2 +- + src/liblzma/check/crc_macros.h | 2 +- + src/liblzma/check/sha256.c | 53 +- + src/liblzma/common/Makefile.am | 31 +- + src/liblzma/common/alignment.c | 5 +- + src/liblzma/common/alone_decoder.c | 77 +- + src/liblzma/common/alone_encoder.c | 99 ++- + src/liblzma/common/auto_decoder.c | 18 +- + src/liblzma/common/block_decoder.c | 298 ++------ + src/liblzma/common/block_encoder.c | 228 ++---- + src/liblzma/common/block_header_decoder.c | 400 ++-------- + src/liblzma/common/block_header_encoder.c | 207 ++---- + src/liblzma/common/block_private.h | 51 +- + src/liblzma/common/block_util.c | 73 ++ + src/liblzma/common/common.h | 44 +- + src/liblzma/common/copy_coder.c | 144 ---- + src/liblzma/common/copy_coder.h | 31 - + src/liblzma/common/delta_common.c | 4 - + src/liblzma/common/delta_common.h | 4 - + src/liblzma/common/delta_decoder.c | 55 +- + src/liblzma/common/delta_encoder.c | 7 +- + src/liblzma/common/{easy_multi.c => easy.c} | 87 ++- + src/liblzma/common/easy_common.c | 54 -- + src/liblzma/common/extra.c | 34 - + src/liblzma/common/features.c | 4 - + src/liblzma/common/filter_flags_decoder.c | 384 +++------- + src/liblzma/common/filter_flags_encoder.c | 120 +-- + src/liblzma/common/index.c | 773 ++++++++++++++++--- + src/liblzma/common/index.h | 67 ++ + src/liblzma/common/index_decoder.c | 252 +++++++ + src/liblzma/common/index_encoder.c | 222 ++++++ + .../{stream_encoder_multi.h => index_encoder.h} | 18 +- + src/liblzma/common/index_hash.c | 340 +++++++++ + src/liblzma/common/info.c | 814 --------------------- + src/liblzma/common/memory_usage.c | 1 - + src/liblzma/common/metadata_decoder.c | 578 --------------- + src/liblzma/common/metadata_decoder.h | 31 - + src/liblzma/common/metadata_encoder.c | 435 ----------- + src/liblzma/common/raw_common.c | 178 ++--- + src/liblzma/common/raw_common.h | 5 +- + src/liblzma/common/raw_decoder.c | 19 +- + src/liblzma/common/raw_decoder.h | 3 +- + src/liblzma/common/raw_encoder.c | 101 +-- + src/liblzma/common/raw_encoder.h | 3 +- + src/liblzma/common/stream_common.h | 3 + + src/liblzma/common/stream_decoder.c | 458 ++++-------- + .../common/{easy_common.h => stream_decoder.h} | 14 +- + src/liblzma/common/stream_encoder.c | 282 +++++++ + .../{metadata_encoder.h => stream_encoder.h} | 14 +- + src/liblzma/common/stream_encoder_multi.c | 445 ----------- + src/liblzma/common/stream_encoder_single.c | 219 ------ + src/liblzma/common/stream_flags_decoder.c | 260 ++----- + src/liblzma/common/stream_flags_encoder.c | 56 +- + .../common/{easy_single.c => stream_flags_equal.c} | 27 +- + src/liblzma/common/vli_decoder.c | 68 +- + src/liblzma/common/vli_encoder.c | 59 +- + src/liblzma/common/vli_reverse_decoder.c | 55 -- + src/liblzma/lz/lz_decoder.c | 6 +- + src/liblzma/lz/lz_decoder.h | 10 +- + src/liblzma/lzma/lzma_decoder.c | 13 +- + src/liblzma/lzma/lzma_decoder.h | 10 +- + src/liblzma/simple/simple_coder.c | 29 +- + src/liblzma/simple/simple_private.h | 4 - + src/liblzma/subblock/subblock_decoder.c | 106 +-- + src/liblzma/subblock/subblock_decoder_helper.c | 5 +- + src/liblzma/subblock/subblock_encoder.c | 8 +- + src/lzma/args.c | 22 +- + src/lzma/args.h | 2 - + src/lzma/error.c | 6 + + src/lzma/process.c | 26 +- + src/lzmadec/lzmadec.c | 8 +- + tests/Makefile.am | 5 +- + tests/test_block_header.c | 411 ++++------- + tests/test_compress.sh | 65 +- + tests/test_filter_flags.c | 116 ++- + tests/test_index.c | 504 ++++++++++++- + tests/test_info.c | 717 ------------------ + tests/test_stream_flags.c | 134 ++-- + tests/tests.h | 14 +- + 109 files changed, 4655 insertions(+), 7965 deletions(-) commit bf6348d1a3ff09fdc06940468f318f75ffa6af11 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -12825,17 +13248,16 @@ Date: 2008-04-28 17:06:34 +0300 Fixed wrong spelling "limitter" to "limiter". This affects liblzma's API. - doc/liblzma-security.txt | 14 +- - src/liblzma/api/lzma/base.h | 4 +- - src/liblzma/api/lzma/memlimit.h | 10 +- - src/liblzma/api/lzma/stream.h | 4 +- - src/liblzma/common/Makefile.am | 2 +- - src/liblzma/common/memory_limiter.c | 288 +++++++++++++++++++++++++++++++++++ - src/liblzma/common/memory_limitter.c | 288 ----------------------------------- - src/lzma/list.c | 6 +- - src/lzmadec/lzmadec.c | 12 +- - tests/test_memlimit.c | 4 +- - 10 files changed, 316 insertions(+), 316 deletions(-) + doc/liblzma-security.txt | 14 +++++++------- + src/liblzma/api/lzma/base.h | 4 ++-- + src/liblzma/api/lzma/memlimit.h | 10 +++++----- + src/liblzma/api/lzma/stream.h | 4 ++-- + src/liblzma/common/Makefile.am | 2 +- + src/liblzma/common/{memory_limitter.c => memory_limiter.c} | 2 +- + src/lzma/list.c | 6 +++--- + src/lzmadec/lzmadec.c | 12 ++++++------ + tests/test_memlimit.c | 4 ++-- + 9 files changed, 29 insertions(+), 29 deletions(-) commit beeb81060821dfec4e7898e0d44b7900dcb2215e Author: Lasse Collin <lasse.collin@tukaani.org> @@ -13656,18 +14078,17 @@ Date: 2008-01-19 15:19:21 +0200 Support for LZMA_SYNC_FLUSH was added to the Delta encoder. This doesn't change anything in the file format. - src/liblzma/common/Makefile.am | 14 ++- - src/liblzma/common/delta_coder.c | 189 ------------------------------------- - src/liblzma/common/delta_coder.h | 31 ------ - src/liblzma/common/delta_common.c | 70 ++++++++++++++ - src/liblzma/common/delta_common.h | 48 ++++++++++ - src/liblzma/common/delta_decoder.c | 102 ++++++++++++++++++++ - src/liblzma/common/delta_decoder.h | 28 ++++++ - src/liblzma/common/delta_encoder.c | 97 +++++++++++++++++++ - src/liblzma/common/delta_encoder.h | 28 ++++++ - src/liblzma/common/raw_decoder.c | 2 +- - src/liblzma/common/raw_encoder.c | 2 +- - 11 files changed, 387 insertions(+), 224 deletions(-) + src/liblzma/common/Makefile.am | 14 +- + src/liblzma/common/delta_coder.c | 189 --------------------- + src/liblzma/common/delta_common.c | 70 ++++++++ + src/liblzma/common/delta_common.h | 48 ++++++ + src/liblzma/common/delta_decoder.c | 102 +++++++++++ + .../common/{delta_coder.h => delta_decoder.h} | 11 +- + src/liblzma/common/delta_encoder.c | 97 +++++++++++ + src/liblzma/common/delta_encoder.h | 28 +++ + src/liblzma/common/raw_decoder.c | 2 +- + src/liblzma/common/raw_encoder.c | 2 +- + 10 files changed, 363 insertions(+), 200 deletions(-) commit 61dc82f3e306b25ce3cd3d529df9ec7a0ec04b73 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -14001,15 +14422,14 @@ Date: 2008-01-15 07:40:21 +0200 Added precomputed range coder probability price table. - src/liblzma/common/init_encoder.c | 5 ++- - src/liblzma/rangecoder/Makefile.am | 9 +++- - src/liblzma/rangecoder/price_table.c | 70 +++++++++++++++++++++++++++++++ - src/liblzma/rangecoder/price_table_gen.c | 55 ++++++++++++++++++++++++ - src/liblzma/rangecoder/price_table_init.c | 48 +++++++++++++++++++++ - src/liblzma/rangecoder/range_common.h | 4 +- - src/liblzma/rangecoder/range_encoder.c | 46 -------------------- - src/liblzma/rangecoder/range_encoder.h | 21 +++++----- - 8 files changed, 197 insertions(+), 61 deletions(-) + src/liblzma/common/init_encoder.c | 5 +- + src/liblzma/rangecoder/Makefile.am | 9 ++- + src/liblzma/rangecoder/price_table.c | 70 ++++++++++++++++++++++ + src/liblzma/rangecoder/price_table_gen.c | 55 +++++++++++++++++ + .../{range_encoder.c => price_table_init.c} | 6 +- + src/liblzma/rangecoder/range_common.h | 4 +- + src/liblzma/rangecoder/range_encoder.h | 21 ++++--- + 7 files changed, 153 insertions(+), 17 deletions(-) commit 362dc3843b373c1007a50a4719f378981f18ae03 Author: Lasse Collin <lasse.collin@tukaani.org> @@ -14199,10 +14619,9 @@ Date: 2008-01-08 13:35:36 +0200 tests/files/bad-cat-single-none-pad_garbage_1.lzma | Bin 0 -> 65 bytes tests/files/bad-cat-single-none-pad_garbage_2.lzma | Bin 0 -> 65 bytes tests/files/bad-cat-single-none-pad_garbage_3.lzma | Bin 0 -> 65 bytes - tests/files/bad-single-data_after_eopm.lzma | Bin 55 -> 0 bytes - tests/files/bad-single-data_after_eopm_1.lzma | Bin 0 -> 55 bytes + ...eopm.lzma => bad-single-data_after_eopm_1.lzma} | Bin tests/files/bad-single-none-truncated.lzma | Bin 0 -> 29 bytes - 7 files changed, 18 insertions(+), 3 deletions(-) + 6 files changed, 18 insertions(+), 3 deletions(-) commit b4943ccf73b64fc93a90a23474509c316f55eb2b Author: Lasse Collin <lasse.collin@tukaani.org> @@ -14292,12 +14711,10 @@ Date: 2008-01-07 14:19:05 +0200 Cleaned up the tests/files directory. - tests/files/bad-single-subblock-padding_loop.lzma | Bin 0 -> 43 bytes - tests/files/bad-single-subblock1023-slow.lzma | Bin 0 -> 7886 bytes - tests/files/malicious-single-subblock-loop.lzma | Bin 43 -> 0 bytes - tests/files/malicious-single-subblock-lzma.lzma | Bin 505 -> 0 bytes - tests/files/malicious-single-subblock1023-slow.lzma | Bin 7886 -> 0 bytes - 5 files changed, 0 insertions(+), 0 deletions(-) + ...ck-loop.lzma => bad-single-subblock-padding_loop.lzma} | Bin + ...ck1023-slow.lzma => bad-single-subblock1023-slow.lzma} | Bin + tests/files/malicious-single-subblock-lzma.lzma | Bin 505 -> 0 bytes + 3 files changed, 0 insertions(+), 0 deletions(-) commit 908b2ac604b9940369d7fe8a45e9eb6da5d2a24c Author: Lasse Collin <lasse.collin@tukaani.org> @@ -14483,12 +14900,10 @@ Date: 2007-12-14 10:07:10 +0200 which are not supported by some non-GNU assemblers (Solaris) that otherwise work with this code. - src/liblzma/check/Makefile.am | 4 +- - src/liblzma/check/crc32_x86.S | 217 ++++++++++++++++++++++++++++++++++++++++++ - src/liblzma/check/crc32_x86.s | 217 ------------------------------------------ - src/liblzma/check/crc64_x86.S | 203 +++++++++++++++++++++++++++++++++++++++ - src/liblzma/check/crc64_x86.s | 203 --------------------------------------- - 5 files changed, 422 insertions(+), 422 deletions(-) + src/liblzma/check/Makefile.am | 4 ++-- + src/liblzma/check/{crc32_x86.s => crc32_x86.S} | 0 + src/liblzma/check/{crc64_x86.s => crc64_x86.S} | 0 + 3 files changed, 2 insertions(+), 2 deletions(-) commit ec1c82b2e82f395f6e8e19ac212a639644330cd7 Author: Lasse Collin <lasse.collin@tukaani.org> diff --git a/contrib/xz/THANKS b/contrib/xz/THANKS index d9c62d468135..1f40c65624e1 100644 --- a/contrib/xz/THANKS +++ b/contrib/xz/THANKS @@ -64,6 +64,7 @@ has been important. :-) In alphabetical order: - Conley Moorhous - Rafał Mużyło - Adrien Nader + - Evan Nemerson - Hongbo Ni - Jonathan Nieder - Andre Noll @@ -74,6 +75,7 @@ has been important. :-) In alphabetical order: - Diego Elio Pettenò - Elbert Pol - Mikko Pouru + - Rich Prohaska - Trần Ngọc Quân - Pavel Raiskup - Ole André Vadla Ravnås @@ -89,6 +91,7 @@ has been important. :-) In alphabetical order: - Andreas Schwab - Dan Shechter - Stuart Shelton + - Sebastian Andrzej Siewior - Brad Smith - Jonathan Stott - Dan Stromberg @@ -102,6 +105,7 @@ has been important. :-) In alphabetical order: - Christian Weisgerber - Bert Wesarg - Fredrik Wikstrom + - Jim Wilcoxson - Ralf Wildenhues - Charles Wilson - Lars Wirzenius diff --git a/contrib/xz/src/common/tuklib_cpucores.c b/contrib/xz/src/common/tuklib_cpucores.c index e235fd1cedc3..c16e188d5362 100644 --- a/contrib/xz/src/common/tuklib_cpucores.c +++ b/contrib/xz/src/common/tuklib_cpucores.c @@ -18,6 +18,10 @@ # endif # include <windows.h> +// glibc >= 2.9 +#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY) +# include <sched.h> + // FreeBSD #elif defined(TUKLIB_CPUCORES_CPUSET) # include <sys/param.h> @@ -49,6 +53,11 @@ tuklib_cpucores(void) GetSystemInfo(&sysinfo); ret = sysinfo.dwNumberOfProcessors; +#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY) + cpu_set_t cpu_mask; + if (sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask) == 0) + ret = CPU_COUNT(&cpu_mask); + #elif defined(TUKLIB_CPUCORES_CPUSET) cpuset_t set; if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, diff --git a/contrib/xz/src/common/tuklib_physmem.c b/contrib/xz/src/common/tuklib_physmem.c index cd2437d8c7d5..4053ad006a64 100644 --- a/contrib/xz/src/common/tuklib_physmem.c +++ b/contrib/xz/src/common/tuklib_physmem.c @@ -86,7 +86,8 @@ tuklib_physmem(void) // GlobalMemoryStatusEx() conditionally. HMODULE kernel32 = GetModuleHandle("kernel32.dll"); if (kernel32 != NULL) { - BOOL (WINAPI *gmse)(LPMEMORYSTATUSEX) = GetProcAddress( + typedef BOOL (WINAPI *gmse_type)(LPMEMORYSTATUSEX); + gmse_type gmse = (gmse_type)GetProcAddress( kernel32, "GlobalMemoryStatusEx"); if (gmse != NULL) { MEMORYSTATUSEX meminfo; diff --git a/contrib/xz/src/liblzma/api/lzma/version.h b/contrib/xz/src/liblzma/api/lzma/version.h index 8bdc7f0b6e76..b5e061c26801 100644 --- a/contrib/xz/src/liblzma/api/lzma/version.h +++ b/contrib/xz/src/liblzma/api/lzma/version.h @@ -22,7 +22,7 @@ */ #define LZMA_VERSION_MAJOR 5 #define LZMA_VERSION_MINOR 2 -#define LZMA_VERSION_PATCH 2 +#define LZMA_VERSION_PATCH 3 #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #ifndef LZMA_VERSION_COMMIT diff --git a/contrib/xz/src/liblzma/check/check.h b/contrib/xz/src/liblzma/check/check.h index 0f96f65b360c..3007d889b0f3 100644 --- a/contrib/xz/src/liblzma/check/check.h +++ b/contrib/xz/src/liblzma/check/check.h @@ -15,7 +15,18 @@ #include "common.h" -#if defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H) +// If the function for external SHA-256 is missing, use the internal SHA-256 +// code. Due to how configure works, these defines can only get defined when +// both a usable header and a type have already been found. +#if !(defined(HAVE_CC_SHA256_INIT) \ + || defined(HAVE_SHA256_INIT) \ + || defined(HAVE_SHA256INIT)) +# define HAVE_INTERNAL_SHA256 1 +#endif + +#if defined(HAVE_INTERNAL_SHA256) +// Nothing +#elif defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H) # include <CommonCrypto/CommonDigest.h> #elif defined(HAVE_SHA256_H) # include <sys/types.h> @@ -23,18 +34,9 @@ #elif defined(HAVE_SHA2_H) # include <sys/types.h> # include <sha2.h> -#elif defined(HAVE_MINIX_SHA2_H) -# include <sys/types.h> -# include <minix/sha2.h> #endif -#if defined(HAVE_CC_SHA256_CTX) -typedef CC_SHA256_CTX lzma_sha256_state; -#elif defined(HAVE_SHA256_CTX) -typedef SHA256_CTX lzma_sha256_state; -#elif defined(HAVE_SHA2_CTX) -typedef SHA2_CTX lzma_sha256_state; -#else +#if defined(HAVE_INTERNAL_SHA256) /// State for the internal SHA-256 implementation typedef struct { /// Internal state @@ -43,9 +45,17 @@ typedef struct { /// Size of the message excluding padding uint64_t size; } lzma_sha256_state; +#elif defined(HAVE_CC_SHA256_CTX) +typedef CC_SHA256_CTX lzma_sha256_state; +#elif defined(HAVE_SHA256_CTX) +typedef SHA256_CTX lzma_sha256_state; +#elif defined(HAVE_SHA2_CTX) +typedef SHA2_CTX lzma_sha256_state; #endif -#if defined(HAVE_CC_SHA256_INIT) +#if defined(HAVE_INTERNAL_SHA256) +// Nothing +#elif defined(HAVE_CC_SHA256_INIT) # define LZMA_SHA256FUNC(x) CC_SHA256_ ## x #elif defined(HAVE_SHA256_INIT) # define LZMA_SHA256FUNC(x) SHA256_ ## x diff --git a/contrib/xz/src/liblzma/common/alone_decoder.c b/contrib/xz/src/liblzma/common/alone_decoder.c index c1360ca1eb7a..dd681765423e 100644 --- a/contrib/xz/src/liblzma/common/alone_decoder.c +++ b/contrib/xz/src/liblzma/common/alone_decoder.c @@ -15,7 +15,7 @@ #include "lz_decoder.h" -struct lzma_coder_s { +typedef struct { lzma_next_coder next; enum { @@ -46,17 +46,19 @@ struct lzma_coder_s { /// Options decoded from the header needed to initialize /// the LZMA decoder lzma_options_lzma options; -}; +} lzma_alone_coder; static lzma_ret -alone_decode(lzma_coder *coder, +alone_decode(void *coder_ptr, const lzma_allocator *allocator lzma_attribute((__unused__)), const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_alone_coder *coder = coder_ptr; + while (*out_pos < out_size && (coder->sequence == SEQ_CODE || *in_pos < in_size)) switch (coder->sequence) { @@ -166,8 +168,9 @@ alone_decode(lzma_coder *coder, static void -alone_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +alone_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_alone_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -175,9 +178,11 @@ alone_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, +alone_decoder_memconfig(void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { + lzma_alone_coder *coder = coder_ptr; + *memusage = coder->memusage; *old_memlimit = coder->memlimit; @@ -201,26 +206,29 @@ lzma_alone_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (memlimit == 0) return LZMA_PROG_ERROR; - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_alone_coder *coder = next->coder; + + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_alone_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &alone_decode; next->end = &alone_decoder_end; next->memconfig = &alone_decoder_memconfig; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } - next->coder->sequence = SEQ_PROPERTIES; - next->coder->picky = picky; - next->coder->pos = 0; - next->coder->options.dict_size = 0; - next->coder->options.preset_dict = NULL; - next->coder->options.preset_dict_size = 0; - next->coder->uncompressed_size = 0; - next->coder->memlimit = memlimit; - next->coder->memusage = LZMA_MEMUSAGE_BASE; + coder->sequence = SEQ_PROPERTIES; + coder->picky = picky; + coder->pos = 0; + coder->options.dict_size = 0; + coder->options.preset_dict = NULL; + coder->options.preset_dict_size = 0; + coder->uncompressed_size = 0; + coder->memlimit = memlimit; + coder->memusage = LZMA_MEMUSAGE_BASE; return LZMA_OK; } diff --git a/contrib/xz/src/liblzma/common/alone_encoder.c b/contrib/xz/src/liblzma/common/alone_encoder.c index a2bc9eee1fa9..4853cfd1d648 100644 --- a/contrib/xz/src/liblzma/common/alone_encoder.c +++ b/contrib/xz/src/liblzma/common/alone_encoder.c @@ -17,7 +17,7 @@ #define ALONE_HEADER_SIZE (1 + 4 + 8) -struct lzma_coder_s { +typedef struct { lzma_next_coder next; enum { @@ -27,17 +27,19 @@ struct lzma_coder_s { size_t header_pos; uint8_t header[ALONE_HEADER_SIZE]; -}; +} lzma_alone_coder; static lzma_ret -alone_encode(lzma_coder *coder, +alone_encode(void *coder_ptr, const lzma_allocator *allocator lzma_attribute((__unused__)), const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_alone_coder *coder = coder_ptr; + while (*out_pos < out_size) switch (coder->sequence) { case SEQ_HEADER: @@ -65,8 +67,9 @@ alone_encode(lzma_coder *coder, static void -alone_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +alone_encoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_alone_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -80,23 +83,26 @@ alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, { lzma_next_coder_init(&alone_encoder_init, next, allocator); - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_alone_coder *coder = next->coder; + + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_alone_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &alone_encode; next->end = &alone_encoder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } // Basic initializations - next->coder->sequence = SEQ_HEADER; - next->coder->header_pos = 0; + coder->sequence = SEQ_HEADER; + coder->header_pos = 0; // Encode the header: // - Properties (1 byte) - if (lzma_lzma_lclppb_encode(options, next->coder->header)) + if (lzma_lzma_lclppb_encode(options, coder->header)) return LZMA_OPTIONS_ERROR; // - Dictionary size (4 bytes) @@ -116,10 +122,10 @@ alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (d != UINT32_MAX) ++d; - unaligned_write32le(next->coder->header + 1, d); + unaligned_write32le(coder->header + 1, d); // - Uncompressed size (always unknown and using EOPM) - memset(next->coder->header + 1 + 4, 0xFF, 8); + memset(coder->header + 1 + 4, 0xFF, 8); // Initialize the LZMA encoder. const lzma_filter_info filters[2] = { @@ -131,7 +137,7 @@ alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, } }; - return lzma_next_filter_init(&next->coder->next, allocator, filters); + return lzma_next_filter_init(&coder->next, allocator, filters); } diff --git a/contrib/xz/src/liblzma/common/auto_decoder.c b/contrib/xz/src/liblzma/common/auto_decoder.c index bf3550701fe6..09acd6dc0958 100644 --- a/contrib/xz/src/liblzma/common/auto_decoder.c +++ b/contrib/xz/src/liblzma/common/auto_decoder.c @@ -14,7 +14,7 @@ #include "alone_decoder.h" -struct lzma_coder_s { +typedef struct { /// Stream decoder or LZMA_Alone decoder lzma_next_coder next; @@ -26,15 +26,17 @@ struct lzma_coder_s { SEQ_CODE, SEQ_FINISH, } sequence; -}; +} lzma_auto_coder; static lzma_ret -auto_decode(lzma_coder *coder, const lzma_allocator *allocator, +auto_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_auto_coder *coder = coder_ptr; + switch (coder->sequence) { case SEQ_INIT: if (*in_pos >= in_size) @@ -100,8 +102,9 @@ auto_decode(lzma_coder *coder, const lzma_allocator *allocator, static void -auto_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +auto_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_auto_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -109,8 +112,10 @@ auto_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_check -auto_decoder_get_check(const lzma_coder *coder) +auto_decoder_get_check(const void *coder_ptr) { + const lzma_auto_coder *coder = coder_ptr; + // It is LZMA_Alone if get_check is NULL. return coder->next.get_check == NULL ? LZMA_CHECK_NONE : coder->next.get_check(coder->next.coder); @@ -118,9 +123,11 @@ auto_decoder_get_check(const lzma_coder *coder) static lzma_ret -auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, +auto_decoder_memconfig(void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { + lzma_auto_coder *coder = coder_ptr; + lzma_ret ret; if (coder->next.memconfig != NULL) { @@ -154,21 +161,23 @@ auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (flags & ~LZMA_SUPPORTED_FLAGS) return LZMA_OPTIONS_ERROR; - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_auto_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_auto_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &auto_decode; next->end = &auto_decoder_end; next->get_check = &auto_decoder_get_check; next->memconfig = &auto_decoder_memconfig; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } - next->coder->memlimit = memlimit; - next->coder->flags = flags; - next->coder->sequence = SEQ_INIT; + coder->memlimit = memlimit; + coder->flags = flags; + coder->sequence = SEQ_INIT; return LZMA_OK; } diff --git a/contrib/xz/src/liblzma/common/block_decoder.c b/contrib/xz/src/liblzma/common/block_decoder.c index 685c3b038fc3..075bd279ff60 100644 --- a/contrib/xz/src/liblzma/common/block_decoder.c +++ b/contrib/xz/src/liblzma/common/block_decoder.c @@ -15,7 +15,7 @@ #include "check.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_CODE, SEQ_PADDING, @@ -48,7 +48,7 @@ struct lzma_coder_s { /// True if the integrity check won't be calculated and verified. bool ignore_check; -}; +} lzma_block_coder; static inline bool @@ -74,11 +74,13 @@ is_size_valid(lzma_vli size, lzma_vli reference) static lzma_ret -block_decode(lzma_coder *coder, const lzma_allocator *allocator, +block_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_block_coder *coder = coder_ptr; + switch (coder->sequence) { case SEQ_CODE: { const size_t in_start = *in_pos; @@ -177,8 +179,9 @@ block_decode(lzma_coder *coder, const lzma_allocator *allocator, static void -block_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +block_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_block_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -198,27 +201,29 @@ lzma_block_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, || !lzma_vli_is_valid(block->uncompressed_size)) return LZMA_PROG_ERROR; - // Allocate and initialize *next->coder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + // Allocate *next->coder if needed. + lzma_block_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_block_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &block_decode; next->end = &block_decoder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } // Basic initializations - next->coder->sequence = SEQ_CODE; - next->coder->block = block; - next->coder->compressed_size = 0; - next->coder->uncompressed_size = 0; + coder->sequence = SEQ_CODE; + coder->block = block; + coder->compressed_size = 0; + coder->uncompressed_size = 0; // If Compressed Size is not known, we calculate the maximum allowed // value so that encoded size of the Block (including Block Padding) // is still a valid VLI and a multiple of four. - next->coder->compressed_limit + coder->compressed_limit = block->compressed_size == LZMA_VLI_UNKNOWN ? (LZMA_VLI_MAX & ~LZMA_VLI_C(3)) - block->header_size @@ -228,14 +233,14 @@ lzma_block_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, // Initialize the check. It's caller's problem if the Check ID is not // supported, and the Block decoder cannot verify the Check field. // Caller can test lzma_check_is_supported(block->check). - next->coder->check_pos = 0; - lzma_check_init(&next->coder->check, block->check); + coder->check_pos = 0; + lzma_check_init(&coder->check, block->check); - next->coder->ignore_check = block->version >= 1 + coder->ignore_check = block->version >= 1 ? block->ignore_check : false; // Initialize the filter chain. - return lzma_raw_decoder_init(&next->coder->next, allocator, + return lzma_raw_decoder_init(&coder->next, allocator, block->filters); } diff --git a/contrib/xz/src/liblzma/common/block_encoder.c b/contrib/xz/src/liblzma/common/block_encoder.c index def586410d28..168846ad6899 100644 --- a/contrib/xz/src/liblzma/common/block_encoder.c +++ b/contrib/xz/src/liblzma/common/block_encoder.c @@ -15,7 +15,7 @@ #include "check.h" -struct lzma_coder_s { +typedef struct { /// The filters in the chain; initialized with lzma_raw_decoder_init(). lzma_next_coder next; @@ -41,15 +41,17 @@ struct lzma_coder_s { /// Check of the uncompressed data lzma_check_state check; -}; +} lzma_block_coder; static lzma_ret -block_encode(lzma_coder *coder, const lzma_allocator *allocator, +block_encode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_block_coder *coder = coder_ptr; + // Check that our amount of input stays in proper limits. if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos) return LZMA_DATA_ERROR; @@ -134,8 +136,9 @@ block_encode(lzma_coder *coder, const lzma_allocator *allocator, static void -block_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +block_encoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_block_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -143,10 +146,12 @@ block_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -block_encoder_update(lzma_coder *coder, const lzma_allocator *allocator, +block_encoder_update(void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters lzma_attribute((__unused__)), const lzma_filter *reversed_filters) { + lzma_block_coder *coder = coder_ptr; + if (coder->sequence != SEQ_CODE) return LZMA_PROG_ERROR; @@ -178,30 +183,31 @@ lzma_block_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, return LZMA_UNSUPPORTED_CHECK; // Allocate and initialize *next->coder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_block_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_block_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &block_encode; next->end = &block_encoder_end; next->update = &block_encoder_update; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } // Basic initializations - next->coder->sequence = SEQ_CODE; - next->coder->block = block; - next->coder->compressed_size = 0; - next->coder->uncompressed_size = 0; - next->coder->pos = 0; + coder->sequence = SEQ_CODE; + coder->block = block; + coder->compressed_size = 0; + coder->uncompressed_size = 0; + coder->pos = 0; // Initialize the check - lzma_check_init(&next->coder->check, block->check); + lzma_check_init(&coder->check, block->check); // Initialize the requested filters. - return lzma_raw_encoder_init(&next->coder->next, allocator, - block->filters); + return lzma_raw_encoder_init(&coder->next, allocator, block->filters); } diff --git a/contrib/xz/src/liblzma/common/common.h b/contrib/xz/src/liblzma/common/common.h index 955d784a5b6a..b3d3b7a059b1 100644 --- a/contrib/xz/src/liblzma/common/common.h +++ b/contrib/xz/src/liblzma/common/common.h @@ -88,10 +88,6 @@ #define LZMA_TIMED_OUT 32 -/// Type of encoder/decoder specific data; the actual structure is defined -/// differently in different coders. -typedef struct lzma_coder_s lzma_coder; - typedef struct lzma_next_coder_s lzma_next_coder; typedef struct lzma_filter_info_s lzma_filter_info; @@ -107,7 +103,7 @@ typedef lzma_ret (*lzma_init_function)( /// input and output buffers, but for simplicity they still use this same /// function prototype. typedef lzma_ret (*lzma_code_function)( - lzma_coder *coder, const lzma_allocator *allocator, + void *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, @@ -115,7 +111,7 @@ typedef lzma_ret (*lzma_code_function)( /// Type of a function to free the memory allocated for the coder typedef void (*lzma_end_function)( - lzma_coder *coder, const lzma_allocator *allocator); + void *coder, const lzma_allocator *allocator); /// Raw coder validates and converts an array of lzma_filter structures to @@ -138,7 +134,7 @@ struct lzma_filter_info_s { /// Hold data and function pointers of the next filter in the chain. struct lzma_next_coder_s { /// Pointer to coder-specific data - lzma_coder *coder; + void *coder; /// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't /// point to a filter coder. @@ -160,21 +156,21 @@ struct lzma_next_coder_s { /// Pointer to a function to get progress information. If this is NULL, /// lzma_stream.total_in and .total_out are used instead. - void (*get_progress)(lzma_coder *coder, + void (*get_progress)(void *coder, uint64_t *progress_in, uint64_t *progress_out); /// Pointer to function to return the type of the integrity check. /// Most coders won't support this. - lzma_check (*get_check)(const lzma_coder *coder); + lzma_check (*get_check)(const void *coder); /// Pointer to function to get and/or change the memory usage limit. /// If new_memlimit == 0, the limit is not changed. - lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage, + lzma_ret (*memconfig)(void *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit); /// Update the filter-specific options or the whole filter chain /// in the encoder. - lzma_ret (*update)(lzma_coder *coder, const lzma_allocator *allocator, + lzma_ret (*update)(void *coder, const lzma_allocator *allocator, const lzma_filter *filters, const lzma_filter *reversed_filters); }; diff --git a/contrib/xz/src/liblzma/common/index.c b/contrib/xz/src/liblzma/common/index.c index e897646c0291..26e4e519bc80 100644 --- a/contrib/xz/src/liblzma/common/index.c +++ b/contrib/xz/src/liblzma/common/index.c @@ -202,22 +202,21 @@ index_tree_node_end(index_tree_node *node, const lzma_allocator *allocator, if (node->right != NULL) index_tree_node_end(node->right, allocator, free_func); - if (free_func != NULL) - free_func(node, allocator); - - lzma_free(node, allocator); + free_func(node, allocator); return; } -/// Free the meory allocated for a tree. If free_func is not NULL, -/// it is called on each node before freeing the node. This is used -/// to free the Record groups from each index_stream before freeing -/// the index_stream itself. +/// Free the memory allocated for a tree. Each node is freed using the +/// given free_func which is either &lzma_free or &index_stream_end. +/// The latter is used to free the Record groups from each index_stream +/// before freeing the index_stream itself. static void index_tree_end(index_tree *tree, const lzma_allocator *allocator, void (*free_func)(void *node, const lzma_allocator *allocator)) { + assert(free_func != NULL); + if (tree->root != NULL) index_tree_node_end(tree->root, allocator, free_func); @@ -371,7 +370,8 @@ static void index_stream_end(void *node, const lzma_allocator *allocator) { index_stream *s = node; - index_tree_end(&s->groups, allocator, NULL); + index_tree_end(&s->groups, allocator, &lzma_free); + lzma_free(s, allocator); return; } @@ -829,6 +829,9 @@ lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src, s->groups.rightmost = &newg->node; lzma_free(g, allocator); + + // NOTE: newg isn't leaked here because + // newg == (void *)&newg->node. } } @@ -869,11 +872,8 @@ index_dup_stream(const index_stream *src, const lzma_allocator *allocator) index_stream *dest = index_stream_init(src->node.compressed_base, src->node.uncompressed_base, src->number, src->block_number_base, allocator); - - // Return immediately if allocation failed or if there are - // no groups to duplicate. - if (dest == NULL || src->groups.leftmost == NULL) - return dest; + if (dest == NULL) + return NULL; // Copy the overall information. dest->record_count = src->record_count; @@ -881,6 +881,10 @@ index_dup_stream(const index_stream *src, const lzma_allocator *allocator) dest->stream_flags = src->stream_flags; dest->stream_padding = src->stream_padding; + // Return if there are no groups to duplicate. + if (src->groups.leftmost == NULL) + return dest; + // Allocate memory for the Records. We put all the Records into // a single group. It's simplest and also tends to make // lzma_index_locate() a little bit faster with very big Indexes. diff --git a/contrib/xz/src/liblzma/common/index_decoder.c b/contrib/xz/src/liblzma/common/index_decoder.c index 795d1834cc58..1e33f0b0eb68 100644 --- a/contrib/xz/src/liblzma/common/index_decoder.c +++ b/contrib/xz/src/liblzma/common/index_decoder.c @@ -14,7 +14,7 @@ #include "check.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_INDICATOR, SEQ_COUNT, @@ -50,11 +50,11 @@ struct lzma_coder_s { /// CRC32 of the List of Records field uint32_t crc32; -}; +} lzma_index_coder; static lzma_ret -index_decode(lzma_coder *coder, const lzma_allocator *allocator, +index_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out lzma_attribute((__unused__)), @@ -62,6 +62,8 @@ index_decode(lzma_coder *coder, const lzma_allocator *allocator, size_t out_size lzma_attribute((__unused__)), lzma_action action lzma_attribute((__unused__))) { + lzma_index_coder *coder = coder_ptr; + // Similar optimization as in index_encoder.c const size_t in_start = *in_pos; lzma_ret ret = LZMA_OK; @@ -207,8 +209,9 @@ out: static void -index_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +index_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_index_coder *coder = coder_ptr; lzma_index_end(coder->index, allocator); lzma_free(coder, allocator); return; @@ -216,9 +219,11 @@ index_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, +index_decoder_memconfig(void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { + lzma_index_coder *coder = coder_ptr; + *memusage = lzma_index_memusage(1, coder->count); *old_memlimit = coder->memlimit; @@ -234,7 +239,7 @@ index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, static lzma_ret -index_decoder_reset(lzma_coder *coder, const lzma_allocator *allocator, +index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator, lzma_index **i, uint64_t memlimit) { // Remember the pointer given by the application. We will set it @@ -269,20 +274,22 @@ index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (i == NULL || memlimit == 0) return LZMA_PROG_ERROR; - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_index_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_index_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &index_decode; next->end = &index_decoder_end; next->memconfig = &index_decoder_memconfig; - next->coder->index = NULL; + coder->index = NULL; } else { - lzma_index_end(next->coder->index, allocator); + lzma_index_end(coder->index, allocator); } - return index_decoder_reset(next->coder, allocator, i, memlimit); + return index_decoder_reset(coder, allocator, i, memlimit); } @@ -309,7 +316,7 @@ lzma_index_buffer_decode(lzma_index **i, uint64_t *memlimit, return LZMA_PROG_ERROR; // Initialize the decoder. - lzma_coder coder; + lzma_index_coder coder; return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit)); // Store the input start position so that we can restore it in case diff --git a/contrib/xz/src/liblzma/common/index_encoder.c b/contrib/xz/src/liblzma/common/index_encoder.c index d25ac7d3372b..ac97d0cebf81 100644 --- a/contrib/xz/src/liblzma/common/index_encoder.c +++ b/contrib/xz/src/liblzma/common/index_encoder.c @@ -15,7 +15,7 @@ #include "check.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_INDICATOR, SEQ_COUNT, @@ -37,11 +37,11 @@ struct lzma_coder_s { /// CRC32 of the List of Records field uint32_t crc32; -}; +} lzma_index_coder; static lzma_ret -index_encode(lzma_coder *coder, +index_encode(void *coder_ptr, const lzma_allocator *allocator lzma_attribute((__unused__)), const uint8_t *restrict in lzma_attribute((__unused__)), size_t *restrict in_pos lzma_attribute((__unused__)), @@ -50,6 +50,8 @@ index_encode(lzma_coder *coder, size_t out_size, lzma_action action lzma_attribute((__unused__))) { + lzma_index_coder *coder = coder_ptr; + // Position where to start calculating CRC32. The idea is that we // need to call lzma_crc32() only once per call to index_encode(). const size_t out_start = *out_pos; @@ -159,7 +161,7 @@ out: static void -index_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +index_encoder_end(void *coder, const lzma_allocator *allocator) { lzma_free(coder, allocator); return; @@ -167,7 +169,7 @@ index_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) static void -index_encoder_reset(lzma_coder *coder, const lzma_index *i) +index_encoder_reset(lzma_index_coder *coder, const lzma_index *i) { lzma_index_iter_init(&coder->iter, i); @@ -190,7 +192,7 @@ lzma_index_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, return LZMA_PROG_ERROR; if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); + next->coder = lzma_alloc(sizeof(lzma_index_coder), allocator); if (next->coder == NULL) return LZMA_MEM_ERROR; @@ -230,7 +232,7 @@ lzma_index_buffer_encode(const lzma_index *i, // The Index encoder needs just one small data structure so we can // allocate it on stack. - lzma_coder coder; + lzma_index_coder coder; index_encoder_reset(&coder, i); // Do the actual encoding. This should never fail, but store diff --git a/contrib/xz/src/liblzma/common/stream_decoder.c b/contrib/xz/src/liblzma/common/stream_decoder.c index 3ab938c9f142..7ae7a670a46a 100644 --- a/contrib/xz/src/liblzma/common/stream_decoder.c +++ b/contrib/xz/src/liblzma/common/stream_decoder.c @@ -14,7 +14,7 @@ #include "block_decoder.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_STREAM_HEADER, SEQ_BLOCK_HEADER, @@ -80,11 +80,11 @@ struct lzma_coder_s { /// Buffer to hold Stream Header, Block Header, and Stream Footer. /// Block Header has biggest maximum size. uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX]; -}; +} lzma_stream_coder; static lzma_ret -stream_decoder_reset(lzma_coder *coder, const lzma_allocator *allocator) +stream_decoder_reset(lzma_stream_coder *coder, const lzma_allocator *allocator) { // Initialize the Index hash used to verify the Index. coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator); @@ -100,11 +100,13 @@ stream_decoder_reset(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -stream_decode(lzma_coder *coder, const lzma_allocator *allocator, +stream_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_stream_coder *coder = coder_ptr; + // When decoding the actual Block, it may be able to produce more // output even if we don't give it any new input. while (true) @@ -375,8 +377,9 @@ stream_decode(lzma_coder *coder, const lzma_allocator *allocator, static void -stream_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +stream_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_stream_coder *coder = coder_ptr; lzma_next_end(&coder->block_decoder, allocator); lzma_index_hash_end(coder->index_hash, allocator); lzma_free(coder, allocator); @@ -385,16 +388,19 @@ stream_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_check -stream_decoder_get_check(const lzma_coder *coder) +stream_decoder_get_check(const void *coder_ptr) { + const lzma_stream_coder *coder = coder_ptr; return coder->stream_flags.check; } static lzma_ret -stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, +stream_decoder_memconfig(void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { + lzma_stream_coder *coder = coder_ptr; + *memusage = coder->memusage; *old_memlimit = coder->memlimit; @@ -422,31 +428,33 @@ lzma_stream_decoder_init( if (flags & ~LZMA_SUPPORTED_FLAGS) return LZMA_OPTIONS_ERROR; - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_stream_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_stream_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &stream_decode; next->end = &stream_decoder_end; next->get_check = &stream_decoder_get_check; next->memconfig = &stream_decoder_memconfig; - next->coder->block_decoder = LZMA_NEXT_CODER_INIT; - next->coder->index_hash = NULL; + coder->block_decoder = LZMA_NEXT_CODER_INIT; + coder->index_hash = NULL; } - next->coder->memlimit = memlimit; - next->coder->memusage = LZMA_MEMUSAGE_BASE; - next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0; - next->coder->tell_unsupported_check + coder->memlimit = memlimit; + coder->memusage = LZMA_MEMUSAGE_BASE; + coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0; + coder->tell_unsupported_check = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0; - next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0; - next->coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0; - next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0; - next->coder->first_stream = true; + coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0; + coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0; + coder->concatenated = (flags & LZMA_CONCATENATED) != 0; + coder->first_stream = true; - return stream_decoder_reset(next->coder, allocator); + return stream_decoder_reset(coder, allocator); } diff --git a/contrib/xz/src/liblzma/common/stream_encoder.c b/contrib/xz/src/liblzma/common/stream_encoder.c index a7663bc48db3..858cba473ad4 100644 --- a/contrib/xz/src/liblzma/common/stream_encoder.c +++ b/contrib/xz/src/liblzma/common/stream_encoder.c @@ -14,7 +14,7 @@ #include "index_encoder.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_STREAM_HEADER, SEQ_BLOCK_INIT, @@ -55,11 +55,11 @@ struct lzma_coder_s { /// Buffer to hold Stream Header, Block Header, and Stream Footer. /// Block Header has biggest maximum size. uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX]; -}; +} lzma_stream_coder; static lzma_ret -block_encoder_init(lzma_coder *coder, const lzma_allocator *allocator) +block_encoder_init(lzma_stream_coder *coder, const lzma_allocator *allocator) { // Prepare the Block options. Even though Block encoder doesn't need // compressed_size, uncompressed_size, and header_size to be @@ -78,11 +78,13 @@ block_encoder_init(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -stream_encode(lzma_coder *coder, const lzma_allocator *allocator, +stream_encode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_stream_coder *coder = coder_ptr; + // Main loop while (*out_pos < out_size) switch (coder->sequence) { @@ -209,8 +211,10 @@ stream_encode(lzma_coder *coder, const lzma_allocator *allocator, static void -stream_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +stream_encoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_stream_coder *coder = coder_ptr; + lzma_next_end(&coder->block_encoder, allocator); lzma_next_end(&coder->index_encoder, allocator); lzma_index_end(coder->index, allocator); @@ -224,10 +228,12 @@ stream_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -stream_encoder_update(lzma_coder *coder, const lzma_allocator *allocator, +stream_encoder_update(void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters, const lzma_filter *reversed_filters) { + lzma_stream_coder *coder = coder_ptr; + if (coder->sequence <= SEQ_BLOCK_INIT) { // There is no incomplete Block waiting to be finished, // thus we can change the whole filter chain. Start by @@ -271,30 +277,33 @@ stream_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (filters == NULL) return LZMA_PROG_ERROR; - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_stream_coder *coder = next->coder; + + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_stream_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &stream_encode; next->end = &stream_encoder_end; next->update = &stream_encoder_update; - next->coder->filters[0].id = LZMA_VLI_UNKNOWN; - next->coder->block_encoder = LZMA_NEXT_CODER_INIT; - next->coder->index_encoder = LZMA_NEXT_CODER_INIT; - next->coder->index = NULL; + coder->filters[0].id = LZMA_VLI_UNKNOWN; + coder->block_encoder = LZMA_NEXT_CODER_INIT; + coder->index_encoder = LZMA_NEXT_CODER_INIT; + coder->index = NULL; } // Basic initializations - next->coder->sequence = SEQ_STREAM_HEADER; - next->coder->block_options.version = 0; - next->coder->block_options.check = check; + coder->sequence = SEQ_STREAM_HEADER; + coder->block_options.version = 0; + coder->block_options.check = check; // Initialize the Index - lzma_index_end(next->coder->index, allocator); - next->coder->index = lzma_index_init(allocator); - if (next->coder->index == NULL) + lzma_index_end(coder->index, allocator); + coder->index = lzma_index_init(allocator); + if (coder->index == NULL) return LZMA_MEM_ERROR; // Encode the Stream Header @@ -303,16 +312,15 @@ stream_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, .check = check, }; return_if_error(lzma_stream_header_encode( - &stream_flags, next->coder->buffer)); + &stream_flags, coder->buffer)); - next->coder->buffer_pos = 0; - next->coder->buffer_size = LZMA_STREAM_HEADER_SIZE; + coder->buffer_pos = 0; + coder->buffer_size = LZMA_STREAM_HEADER_SIZE; // Initialize the Block encoder. This way we detect unsupported // filter chains when initializing the Stream encoder instead of // giving an error after Stream Header has already written out. - return stream_encoder_update( - next->coder, allocator, filters, NULL); + return stream_encoder_update(coder, allocator, filters, NULL); } diff --git a/contrib/xz/src/liblzma/common/stream_encoder_mt.c b/contrib/xz/src/liblzma/common/stream_encoder_mt.c index 9780ed04cac4..2efe44c2534f 100644 --- a/contrib/xz/src/liblzma/common/stream_encoder_mt.c +++ b/contrib/xz/src/liblzma/common/stream_encoder_mt.c @@ -44,6 +44,7 @@ typedef enum { } worker_state; +typedef struct lzma_stream_coder_s lzma_stream_coder; typedef struct worker_thread_s worker_thread; struct worker_thread_s { @@ -65,7 +66,7 @@ struct worker_thread_s { /// Pointer to the main structure is needed when putting this /// thread back to the stack of free threads. - lzma_coder *coder; + lzma_stream_coder *coder; /// The allocator is set by the main thread. Since a copy of the /// pointer is kept here, the application must not change the @@ -96,7 +97,7 @@ struct worker_thread_s { }; -struct lzma_coder_s { +struct lzma_stream_coder_s { enum { SEQ_STREAM_HEADER, SEQ_BLOCK, @@ -417,7 +418,7 @@ worker_start(void *thr_ptr) /// Make the threads stop but not exit. Optionally wait for them to stop. static void -threads_stop(lzma_coder *coder, bool wait_for_threads) +threads_stop(lzma_stream_coder *coder, bool wait_for_threads) { // Tell the threads to stop. for (uint32_t i = 0; i < coder->threads_initialized; ++i) { @@ -446,7 +447,7 @@ threads_stop(lzma_coder *coder, bool wait_for_threads) /// Stop the threads and free the resources associated with them. /// Wait until the threads have exited. static void -threads_end(lzma_coder *coder, const lzma_allocator *allocator) +threads_end(lzma_stream_coder *coder, const lzma_allocator *allocator) { for (uint32_t i = 0; i < coder->threads_initialized; ++i) { mythread_sync(coder->threads[i].mutex) { @@ -468,7 +469,8 @@ threads_end(lzma_coder *coder, const lzma_allocator *allocator) /// Initialize a new worker_thread structure and create a new thread. static lzma_ret -initialize_new_thread(lzma_coder *coder, const lzma_allocator *allocator) +initialize_new_thread(lzma_stream_coder *coder, + const lzma_allocator *allocator) { worker_thread *thr = &coder->threads[coder->threads_initialized]; @@ -510,7 +512,7 @@ error_mutex: static lzma_ret -get_thread(lzma_coder *coder, const lzma_allocator *allocator) +get_thread(lzma_stream_coder *coder, const lzma_allocator *allocator) { // If there are no free output subqueues, there is no // point to try getting a thread. @@ -548,7 +550,7 @@ get_thread(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -stream_encode_in(lzma_coder *coder, const lzma_allocator *allocator, +stream_encode_in(lzma_stream_coder *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, lzma_action action) { @@ -616,7 +618,7 @@ stream_encode_in(lzma_coder *coder, const lzma_allocator *allocator, /// Wait until more input can be consumed, more output can be read, or /// an optional timeout is reached. static bool -wait_for_work(lzma_coder *coder, mythread_condtime *wait_abs, +wait_for_work(lzma_stream_coder *coder, mythread_condtime *wait_abs, bool *has_blocked, bool has_input) { if (coder->timeout != 0 && !*has_blocked) { @@ -662,11 +664,13 @@ wait_for_work(lzma_coder *coder, mythread_condtime *wait_abs, static lzma_ret -stream_encode_mt(lzma_coder *coder, const lzma_allocator *allocator, +stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_stream_coder *coder = coder_ptr; + switch (coder->sequence) { case SEQ_STREAM_HEADER: lzma_bufcpy(coder->header, &coder->header_pos, @@ -834,8 +838,10 @@ stream_encode_mt(lzma_coder *coder, const lzma_allocator *allocator, static void -stream_encoder_mt_end(lzma_coder *coder, const lzma_allocator *allocator) +stream_encoder_mt_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_stream_coder *coder = coder_ptr; + // Threads must be killed before the output queue can be freed. threads_end(coder, allocator); lzma_outq_end(&coder->outq, allocator); @@ -907,10 +913,12 @@ get_options(const lzma_mt *options, lzma_options_easy *opt_easy, static void -get_progress(lzma_coder *coder, uint64_t *progress_in, uint64_t *progress_out) +get_progress(void *coder_ptr, uint64_t *progress_in, uint64_t *progress_out) { + lzma_stream_coder *coder = coder_ptr; + // Lock coder->mutex to prevent finishing threads from moving their - // progress info from the worker_thread structure to lzma_coder. + // progress info from the worker_thread structure to lzma_stream_coder. mythread_sync(coder->mutex) { *progress_in = coder->progress_in; *progress_out = coder->progress_out; @@ -962,24 +970,27 @@ stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator, return LZMA_UNSUPPORTED_CHECK; // Allocate and initialize the base structure if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_stream_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_stream_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; + // For the mutex and condition variable initializations // the error handling has to be done here because // stream_encoder_mt_end() doesn't know if they have // already been initialized or not. - if (mythread_mutex_init(&next->coder->mutex)) { - lzma_free(next->coder, allocator); + if (mythread_mutex_init(&coder->mutex)) { + lzma_free(coder, allocator); next->coder = NULL; return LZMA_MEM_ERROR; } - if (mythread_cond_init(&next->coder->cond)) { - mythread_mutex_destroy(&next->coder->mutex); - lzma_free(next->coder, allocator); + if (mythread_cond_init(&coder->cond)) { + mythread_mutex_destroy(&coder->mutex); + lzma_free(coder, allocator); next->coder = NULL; return LZMA_MEM_ERROR; } @@ -989,76 +1000,76 @@ stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator, next->get_progress = &get_progress; // next->update = &stream_encoder_mt_update; - next->coder->filters[0].id = LZMA_VLI_UNKNOWN; - next->coder->index_encoder = LZMA_NEXT_CODER_INIT; - next->coder->index = NULL; - memzero(&next->coder->outq, sizeof(next->coder->outq)); - next->coder->threads = NULL; - next->coder->threads_max = 0; - next->coder->threads_initialized = 0; + coder->filters[0].id = LZMA_VLI_UNKNOWN; + coder->index_encoder = LZMA_NEXT_CODER_INIT; + coder->index = NULL; + memzero(&coder->outq, sizeof(coder->outq)); + coder->threads = NULL; + coder->threads_max = 0; + coder->threads_initialized = 0; } // Basic initializations - next->coder->sequence = SEQ_STREAM_HEADER; - next->coder->block_size = (size_t)(block_size); - next->coder->thread_error = LZMA_OK; - next->coder->thr = NULL; + coder->sequence = SEQ_STREAM_HEADER; + coder->block_size = (size_t)(block_size); + coder->thread_error = LZMA_OK; + coder->thr = NULL; // Allocate the thread-specific base structures. assert(options->threads > 0); - if (next->coder->threads_max != options->threads) { - threads_end(next->coder, allocator); + if (coder->threads_max != options->threads) { + threads_end(coder, allocator); - next->coder->threads = NULL; - next->coder->threads_max = 0; + coder->threads = NULL; + coder->threads_max = 0; - next->coder->threads_initialized = 0; - next->coder->threads_free = NULL; + coder->threads_initialized = 0; + coder->threads_free = NULL; - next->coder->threads = lzma_alloc( + coder->threads = lzma_alloc( options->threads * sizeof(worker_thread), allocator); - if (next->coder->threads == NULL) + if (coder->threads == NULL) return LZMA_MEM_ERROR; - next->coder->threads_max = options->threads; + coder->threads_max = options->threads; } else { // Reuse the old structures and threads. Tell the running // threads to stop and wait until they have stopped. - threads_stop(next->coder, true); + threads_stop(coder, true); } // Output queue - return_if_error(lzma_outq_init(&next->coder->outq, allocator, + return_if_error(lzma_outq_init(&coder->outq, allocator, outbuf_size_max, options->threads)); // Timeout - next->coder->timeout = options->timeout; + coder->timeout = options->timeout; // Free the old filter chain and copy the new one. - for (size_t i = 0; next->coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i) - lzma_free(next->coder->filters[i].options, allocator); + for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i) + lzma_free(coder->filters[i].options, allocator); return_if_error(lzma_filters_copy( - filters, next->coder->filters, allocator)); + filters, coder->filters, allocator)); // Index - lzma_index_end(next->coder->index, allocator); - next->coder->index = lzma_index_init(allocator); - if (next->coder->index == NULL) + lzma_index_end(coder->index, allocator); + coder->index = lzma_index_init(allocator); + if (coder->index == NULL) return LZMA_MEM_ERROR; // Stream Header - next->coder->stream_flags.version = 0; - next->coder->stream_flags.check = options->check; + coder->stream_flags.version = 0; + coder->stream_flags.check = options->check; return_if_error(lzma_stream_header_encode( - &next->coder->stream_flags, next->coder->header)); + &coder->stream_flags, coder->header)); - next->coder->header_pos = 0; + coder->header_pos = 0; // Progress info - next->coder->progress_in = 0; - next->coder->progress_out = LZMA_STREAM_HEADER_SIZE; + coder->progress_in = 0; + coder->progress_out = LZMA_STREAM_HEADER_SIZE; return LZMA_OK; } @@ -1111,7 +1122,8 @@ lzma_stream_encoder_mt_memusage(const lzma_mt *options) return UINT64_MAX; // Sum them with overflow checking. - uint64_t total_memusage = LZMA_MEMUSAGE_BASE + sizeof(lzma_coder) + uint64_t total_memusage = LZMA_MEMUSAGE_BASE + + sizeof(lzma_stream_coder) + options->threads * sizeof(worker_thread); if (UINT64_MAX - total_memusage < inbuf_memusage) diff --git a/contrib/xz/src/liblzma/delta/delta_common.c b/contrib/xz/src/liblzma/delta/delta_common.c index 13dd46828d87..4768201d1a9f 100644 --- a/contrib/xz/src/liblzma/delta/delta_common.c +++ b/contrib/xz/src/liblzma/delta/delta_common.c @@ -15,8 +15,9 @@ static void -delta_coder_end(lzma_coder *coder, const lzma_allocator *allocator) +delta_coder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_delta_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder, allocator); return; @@ -28,14 +29,17 @@ lzma_delta_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters) { // Allocate memory for the decoder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_delta_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_delta_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; + // End function is the same for encoder and decoder. next->end = &delta_coder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } // Validate the options. @@ -44,15 +48,14 @@ lzma_delta_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, // Set the delta distance. const lzma_options_delta *opt = filters[0].options; - next->coder->distance = opt->dist; + coder->distance = opt->dist; // Initialize the rest of the variables. - next->coder->pos = 0; - memzero(next->coder->history, LZMA_DELTA_DIST_MAX); + coder->pos = 0; + memzero(coder->history, LZMA_DELTA_DIST_MAX); // Initialize the next decoder in the chain, if any. - return lzma_next_filter_init(&next->coder->next, - allocator, filters + 1); + return lzma_next_filter_init(&coder->next, allocator, filters + 1); } @@ -66,5 +69,5 @@ lzma_delta_coder_memusage(const void *options) || opt->dist > LZMA_DELTA_DIST_MAX) return UINT64_MAX; - return sizeof(lzma_coder); + return sizeof(lzma_delta_coder); } diff --git a/contrib/xz/src/liblzma/delta/delta_decoder.c b/contrib/xz/src/liblzma/delta/delta_decoder.c index 726d023991c0..6859afa5cd76 100644 --- a/contrib/xz/src/liblzma/delta/delta_decoder.c +++ b/contrib/xz/src/liblzma/delta/delta_decoder.c @@ -15,7 +15,7 @@ static void -decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size) +decode_buffer(lzma_delta_coder *coder, uint8_t *buffer, size_t size) { const size_t distance = coder->distance; @@ -27,11 +27,13 @@ decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size) static lzma_ret -delta_decode(lzma_coder *coder, const lzma_allocator *allocator, +delta_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_delta_coder *coder = coder_ptr; + assert(coder->next.code != NULL); const size_t out_start = *out_pos; diff --git a/contrib/xz/src/liblzma/delta/delta_encoder.c b/contrib/xz/src/liblzma/delta/delta_encoder.c index 5a842636ba1b..38416515162b 100644 --- a/contrib/xz/src/liblzma/delta/delta_encoder.c +++ b/contrib/xz/src/liblzma/delta/delta_encoder.c @@ -18,7 +18,7 @@ /// is the first filter in the chain (and thus the last filter in the /// encoder's filter stack). static void -copy_and_encode(lzma_coder *coder, +copy_and_encode(lzma_delta_coder *coder, const uint8_t *restrict in, uint8_t *restrict out, size_t size) { const size_t distance = coder->distance; @@ -35,7 +35,7 @@ copy_and_encode(lzma_coder *coder, /// Encodes the data in place. This is used when we are the last filter /// in the chain (and thus non-last filter in the encoder's filter stack). static void -encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size) +encode_in_place(lzma_delta_coder *coder, uint8_t *buffer, size_t size) { const size_t distance = coder->distance; @@ -49,11 +49,13 @@ encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size) static lzma_ret -delta_encode(lzma_coder *coder, const lzma_allocator *allocator, +delta_encode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_delta_coder *coder = coder_ptr; + lzma_ret ret; if (coder->next.code == NULL) { @@ -84,10 +86,12 @@ delta_encode(lzma_coder *coder, const lzma_allocator *allocator, static lzma_ret -delta_encoder_update(lzma_coder *coder, const lzma_allocator *allocator, +delta_encoder_update(void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters_null lzma_attribute((__unused__)), const lzma_filter *reversed_filters) { + lzma_delta_coder *coder = coder_ptr; + // Delta doesn't and will never support changing the options in // the middle of encoding. If the app tries to change them, we // simply ignore them. diff --git a/contrib/xz/src/liblzma/delta/delta_private.h b/contrib/xz/src/liblzma/delta/delta_private.h index 46ce0c645091..0d6cb3866115 100644 --- a/contrib/xz/src/liblzma/delta/delta_private.h +++ b/contrib/xz/src/liblzma/delta/delta_private.h @@ -15,7 +15,7 @@ #include "delta_common.h" -struct lzma_coder_s { +typedef struct { /// Next coder in the chain lzma_next_coder next; @@ -27,7 +27,7 @@ struct lzma_coder_s { /// Buffer to hold history of the original data uint8_t history[LZMA_DELTA_DIST_MAX]; -}; +} lzma_delta_coder; extern lzma_ret lzma_delta_coder_init( diff --git a/contrib/xz/src/liblzma/lz/lz_decoder.c b/contrib/xz/src/liblzma/lz/lz_decoder.c index 2328a8e73f07..c7086440bfa9 100644 --- a/contrib/xz/src/liblzma/lz/lz_decoder.c +++ b/contrib/xz/src/liblzma/lz/lz_decoder.c @@ -20,7 +20,7 @@ #include "lz_decoder.h" -struct lzma_coder_s { +typedef struct { /// Dictionary (history buffer) lzma_dict dict; @@ -48,7 +48,7 @@ struct lzma_coder_s { size_t size; uint8_t buffer[LZMA_BUFFER_SIZE]; } temp; -}; +} lzma_coder; static void @@ -125,13 +125,15 @@ decode_buffer(lzma_coder *coder, static lzma_ret -lz_decode(lzma_coder *coder, +lz_decode(void *coder_ptr, const lzma_allocator *allocator lzma_attribute((__unused__)), const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_coder *coder = coder_ptr; + if (coder->next.code == NULL) return decode_buffer(coder, in, in_pos, in_size, out, out_pos, out_size); @@ -184,8 +186,10 @@ lz_decode(lzma_coder *coder, static void -lz_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +lz_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_coder *coder = coder_ptr; + lzma_next_end(&coder->next, allocator); lzma_free(coder->dict.buf, allocator); @@ -207,24 +211,26 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, lzma_lz_options *lz_options)) { // Allocate the base structure if it isn't already allocated. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &lz_decode; next->end = &lz_decoder_end; - next->coder->dict.buf = NULL; - next->coder->dict.size = 0; - next->coder->lz = LZMA_LZ_DECODER_INIT; - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->dict.buf = NULL; + coder->dict.size = 0; + coder->lz = LZMA_LZ_DECODER_INIT; + coder->next = LZMA_NEXT_CODER_INIT; } // Allocate and initialize the LZ-based decoder. It will also give // us the dictionary size. lzma_lz_options lz_options; - return_if_error(lz_init(&next->coder->lz, allocator, + return_if_error(lz_init(&coder->lz, allocator, filters[0].options, &lz_options)); // If the dictionary size is very small, increase it to 4096 bytes. @@ -248,14 +254,14 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15)); // Allocate and initialize the dictionary. - if (next->coder->dict.size != lz_options.dict_size) { - lzma_free(next->coder->dict.buf, allocator); - next->coder->dict.buf + if (coder->dict.size != lz_options.dict_size) { + lzma_free(coder->dict.buf, allocator); + coder->dict.buf = lzma_alloc(lz_options.dict_size, allocator); - if (next->coder->dict.buf == NULL) + if (coder->dict.buf == NULL) return LZMA_MEM_ERROR; - next->coder->dict.size = lz_options.dict_size; + coder->dict.size = lz_options.dict_size; } lz_decoder_reset(next->coder); @@ -268,21 +274,20 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const size_t copy_size = my_min(lz_options.preset_dict_size, lz_options.dict_size); const size_t offset = lz_options.preset_dict_size - copy_size; - memcpy(next->coder->dict.buf, lz_options.preset_dict + offset, + memcpy(coder->dict.buf, lz_options.preset_dict + offset, copy_size); - next->coder->dict.pos = copy_size; - next->coder->dict.full = copy_size; + coder->dict.pos = copy_size; + coder->dict.full = copy_size; } // Miscellaneous initializations - next->coder->next_finished = false; - next->coder->this_finished = false; - next->coder->temp.pos = 0; - next->coder->temp.size = 0; + coder->next_finished = false; + coder->this_finished = false; + coder->temp.pos = 0; + coder->temp.size = 0; // Initialize the next filter in the chain, if any. - return lzma_next_filter_init(&next->coder->next, allocator, - filters + 1); + return lzma_next_filter_init(&coder->next, allocator, filters + 1); } @@ -294,7 +299,8 @@ lzma_lz_decoder_memusage(size_t dictionary_size) extern void -lzma_lz_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size) +lzma_lz_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size) { + lzma_coder *coder = coder_ptr; coder->lz.set_uncompressed(coder->lz.coder, uncompressed_size); } diff --git a/contrib/xz/src/liblzma/lz/lz_decoder.h b/contrib/xz/src/liblzma/lz/lz_decoder.h index 277900afb714..754ccf37c6a4 100644 --- a/contrib/xz/src/liblzma/lz/lz_decoder.h +++ b/contrib/xz/src/liblzma/lz/lz_decoder.h @@ -53,21 +53,20 @@ typedef struct { typedef struct { /// Data specific to the LZ-based decoder - lzma_coder *coder; + void *coder; /// Function to decode from in[] to *dict - lzma_ret (*code)(lzma_coder *restrict coder, + lzma_ret (*code)(void *coder, lzma_dict *restrict dict, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size); - void (*reset)(lzma_coder *coder, const void *options); + void (*reset)(void *coder, const void *options); /// Set the uncompressed size - void (*set_uncompressed)(lzma_coder *coder, - lzma_vli uncompressed_size); + void (*set_uncompressed)(void *coder, lzma_vli uncompressed_size); /// Free allocated resources - void (*end)(lzma_coder *coder, const lzma_allocator *allocator); + void (*end)(void *coder, const lzma_allocator *allocator); } lzma_lz_decoder; @@ -92,7 +91,7 @@ extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next, extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size); extern void lzma_lz_decoder_uncompressed( - lzma_coder *coder, lzma_vli uncompressed_size); + void *coder, lzma_vli uncompressed_size); ////////////////////// diff --git a/contrib/xz/src/liblzma/lz/lz_encoder.c b/contrib/xz/src/liblzma/lz/lz_encoder.c index 48bc487d6853..9a74b7c47ce8 100644 --- a/contrib/xz/src/liblzma/lz/lz_encoder.c +++ b/contrib/xz/src/liblzma/lz/lz_encoder.c @@ -23,7 +23,7 @@ #include "memcmplen.h" -struct lzma_coder_s { +typedef struct { /// LZ-based encoder e.g. LZMA lzma_lz_encoder lz; @@ -32,7 +32,7 @@ struct lzma_coder_s { /// Next coder in the chain lzma_next_coder next; -}; +} lzma_coder; /// \brief Moves the data in the input window to free space for new data @@ -157,12 +157,14 @@ fill_window(lzma_coder *coder, const lzma_allocator *allocator, static lzma_ret -lz_encode(lzma_coder *coder, const lzma_allocator *allocator, +lz_encode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_coder *coder = coder_ptr; + while (*out_pos < out_size && (*in_pos < in_size || action != LZMA_RUN)) { // Read more data to coder->mf.buffer if needed. @@ -481,8 +483,10 @@ lzma_lz_encoder_memusage(const lzma_lz_options *lz_options) static void -lz_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +lz_encoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_coder *coder = coder_ptr; + lzma_next_end(&coder->next, allocator); lzma_free(coder->mf.son, allocator); @@ -500,10 +504,12 @@ lz_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -lz_encoder_update(lzma_coder *coder, const lzma_allocator *allocator, +lz_encoder_update(void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters_null lzma_attribute((__unused__)), const lzma_filter *reversed_filters) { + lzma_coder *coder = coder_ptr; + if (coder->lz.options_update == NULL) return LZMA_PROG_ERROR; @@ -528,46 +534,51 @@ lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, #endif // Allocate and initialize the base data structure. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) + lzma_coder *coder = next->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &lz_encode; next->end = &lz_encoder_end; next->update = &lz_encoder_update; - next->coder->lz.coder = NULL; - next->coder->lz.code = NULL; - next->coder->lz.end = NULL; - - next->coder->mf.buffer = NULL; - next->coder->mf.hash = NULL; - next->coder->mf.son = NULL; - next->coder->mf.hash_count = 0; - next->coder->mf.sons_count = 0; - - next->coder->next = LZMA_NEXT_CODER_INIT; + coder->lz.coder = NULL; + coder->lz.code = NULL; + coder->lz.end = NULL; + + // mf.size is initialized to silence Valgrind + // when used on optimized binaries (GCC may reorder + // code in a way that Valgrind gets unhappy). + coder->mf.buffer = NULL; + coder->mf.size = 0; + coder->mf.hash = NULL; + coder->mf.son = NULL; + coder->mf.hash_count = 0; + coder->mf.sons_count = 0; + + coder->next = LZMA_NEXT_CODER_INIT; } // Initialize the LZ-based encoder. lzma_lz_options lz_options; - return_if_error(lz_init(&next->coder->lz, allocator, + return_if_error(lz_init(&coder->lz, allocator, filters[0].options, &lz_options)); - // Setup the size information into next->coder->mf and deallocate + // Setup the size information into coder->mf and deallocate // old buffers if they have wrong size. - if (lz_encoder_prepare(&next->coder->mf, allocator, &lz_options)) + if (lz_encoder_prepare(&coder->mf, allocator, &lz_options)) return LZMA_OPTIONS_ERROR; // Allocate new buffers if needed, and do the rest of // the initialization. - if (lz_encoder_init(&next->coder->mf, allocator, &lz_options)) + if (lz_encoder_init(&coder->mf, allocator, &lz_options)) return LZMA_MEM_ERROR; // Initialize the next filter in the chain, if any. - return lzma_next_filter_init(&next->coder->next, allocator, - filters + 1); + return lzma_next_filter_init(&coder->next, allocator, filters + 1); } diff --git a/contrib/xz/src/liblzma/lz/lz_encoder.h b/contrib/xz/src/liblzma/lz/lz_encoder.h index dad9c6b29980..426dcd8a3875 100644 --- a/contrib/xz/src/liblzma/lz/lz_encoder.h +++ b/contrib/xz/src/liblzma/lz/lz_encoder.h @@ -191,19 +191,18 @@ typedef struct { typedef struct { /// Data specific to the LZ-based encoder - lzma_coder *coder; + void *coder; /// Function to encode from *dict to out[] - lzma_ret (*code)(lzma_coder *restrict coder, + lzma_ret (*code)(void *coder, lzma_mf *restrict mf, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size); /// Free allocated resources - void (*end)(lzma_coder *coder, const lzma_allocator *allocator); + void (*end)(void *coder, const lzma_allocator *allocator); /// Update the options in the middle of the encoding. - lzma_ret (*options_update)(lzma_coder *coder, - const lzma_filter *filter); + lzma_ret (*options_update)(void *coder, const lzma_filter *filter); } lzma_lz_encoder; diff --git a/contrib/xz/src/liblzma/lzma/lzma2_decoder.c b/contrib/xz/src/liblzma/lzma/lzma2_decoder.c index 84982d2c4286..878c870ae1a2 100644 --- a/contrib/xz/src/liblzma/lzma/lzma2_decoder.c +++ b/contrib/xz/src/liblzma/lzma/lzma2_decoder.c @@ -16,7 +16,7 @@ #include "lzma_decoder.h" -struct lzma_coder_s { +typedef struct { enum sequence { SEQ_CONTROL, SEQ_UNCOMPRESSED_1, @@ -50,14 +50,16 @@ struct lzma_coder_s { bool need_dictionary_reset; lzma_options_lzma options; -}; +} lzma_lzma2_coder; static lzma_ret -lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, +lzma2_decode(void *coder_ptr, lzma_dict *restrict dict, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size) { + lzma_lzma2_coder *restrict coder = coder_ptr; + // With SEQ_LZMA it is possible that no new input is needed to do // some progress. The rest of the sequences assume that there is // at least one byte of input. @@ -209,8 +211,10 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, static void -lzma2_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) +lzma2_decoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_lzma2_coder *coder = coder_ptr; + assert(coder->lzma.end == NULL); lzma_free(coder->lzma.coder, allocator); @@ -224,25 +228,27 @@ static lzma_ret lzma2_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator, const void *opt, lzma_lz_options *lz_options) { - if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (lz->coder == NULL) + lzma_lzma2_coder *coder = lz->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + lz->coder = coder; lz->code = &lzma2_decode; lz->end = &lzma2_decoder_end; - lz->coder->lzma = LZMA_LZ_DECODER_INIT; + coder->lzma = LZMA_LZ_DECODER_INIT; } const lzma_options_lzma *options = opt; - lz->coder->sequence = SEQ_CONTROL; - lz->coder->need_properties = true; - lz->coder->need_dictionary_reset = options->preset_dict == NULL + coder->sequence = SEQ_CONTROL; + coder->need_properties = true; + coder->need_dictionary_reset = options->preset_dict == NULL || options->preset_dict_size == 0; - return lzma_lzma_decoder_create(&lz->coder->lzma, + return lzma_lzma_decoder_create(&coder->lzma, allocator, options, lz_options); } @@ -263,7 +269,7 @@ lzma_lzma2_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, extern uint64_t lzma_lzma2_decoder_memusage(const void *options) { - return sizeof(lzma_coder) + return sizeof(lzma_lzma2_coder) + lzma_lzma_decoder_memusage_nocheck(options); } diff --git a/contrib/xz/src/liblzma/lzma/lzma2_encoder.c b/contrib/xz/src/liblzma/lzma/lzma2_encoder.c index b6756bfc2b1c..63588ee30c6b 100644 --- a/contrib/xz/src/liblzma/lzma/lzma2_encoder.c +++ b/contrib/xz/src/liblzma/lzma/lzma2_encoder.c @@ -17,7 +17,7 @@ #include "lzma2_encoder.h" -struct lzma_coder_s { +typedef struct { enum { SEQ_INIT, SEQ_LZMA_ENCODE, @@ -27,7 +27,7 @@ struct lzma_coder_s { } sequence; /// LZMA encoder - lzma_coder *lzma; + void *lzma; /// LZMA options currently in use. lzma_options_lzma opt_cur; @@ -48,11 +48,11 @@ struct lzma_coder_s { /// Buffer to hold the chunk header and LZMA compressed data uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX]; -}; +} lzma_lzma2_coder; static void -lzma2_header_lzma(lzma_coder *coder) +lzma2_header_lzma(lzma_lzma2_coder *coder) { assert(coder->uncompressed_size > 0); assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX); @@ -108,7 +108,7 @@ lzma2_header_lzma(lzma_coder *coder) static void -lzma2_header_uncompressed(lzma_coder *coder) +lzma2_header_uncompressed(lzma_lzma2_coder *coder) { assert(coder->uncompressed_size > 0); assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX); @@ -133,10 +133,12 @@ lzma2_header_uncompressed(lzma_coder *coder) static lzma_ret -lzma2_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, +lzma2_encode(void *coder_ptr, lzma_mf *restrict mf, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size) { + lzma_lzma2_coder *restrict coder = coder_ptr; + while (*out_pos < out_size) switch (coder->sequence) { case SEQ_INIT: @@ -262,8 +264,9 @@ lzma2_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, static void -lzma2_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) +lzma2_encoder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_lzma2_coder *coder = coder_ptr; lzma_free(coder->lzma, allocator); lzma_free(coder, allocator); return; @@ -271,8 +274,10 @@ lzma2_encoder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter) +lzma2_encoder_options_update(void *coder_ptr, const lzma_filter *filter) { + lzma_lzma2_coder *coder = coder_ptr; + // New options can be set only when there is no incomplete chunk. // This is the case at the beginning of the raw stream and right // after LZMA_SYNC_FLUSH. @@ -310,30 +315,32 @@ lzma2_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator, if (options == NULL) return LZMA_PROG_ERROR; - if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (lz->coder == NULL) + lzma_lzma2_coder *coder = lz->coder; + if (coder == NULL) { + coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator); + if (coder == NULL) return LZMA_MEM_ERROR; + lz->coder = coder; lz->code = &lzma2_encode; lz->end = &lzma2_encoder_end; lz->options_update = &lzma2_encoder_options_update; - lz->coder->lzma = NULL; + coder->lzma = NULL; } - lz->coder->opt_cur = *(const lzma_options_lzma *)(options); + coder->opt_cur = *(const lzma_options_lzma *)(options); - lz->coder->sequence = SEQ_INIT; - lz->coder->need_properties = true; - lz->coder->need_state_reset = false; - lz->coder->need_dictionary_reset - = lz->coder->opt_cur.preset_dict == NULL - || lz->coder->opt_cur.preset_dict_size == 0; + coder->sequence = SEQ_INIT; + coder->need_properties = true; + coder->need_state_reset = false; + coder->need_dictionary_reset + = coder->opt_cur.preset_dict == NULL + || coder->opt_cur.preset_dict_size == 0; // Initialize LZMA encoder - return_if_error(lzma_lzma_encoder_create(&lz->coder->lzma, allocator, - &lz->coder->opt_cur, lz_options)); + return_if_error(lzma_lzma_encoder_create(&coder->lzma, allocator, + &coder->opt_cur, lz_options)); // Make sure that we will always have enough history available in // case we need to use uncompressed chunks. They are used when the @@ -364,7 +371,7 @@ lzma_lzma2_encoder_memusage(const void *options) if (lzma_mem == UINT64_MAX) return UINT64_MAX; - return sizeof(lzma_coder) + lzma_mem; + return sizeof(lzma_lzma2_coder) + lzma_mem; } diff --git a/contrib/xz/src/liblzma/lzma/lzma_decoder.c b/contrib/xz/src/liblzma/lzma/lzma_decoder.c index b8f931705bf9..eedc0733f9b3 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_decoder.c +++ b/contrib/xz/src/liblzma/lzma/lzma_decoder.c @@ -161,7 +161,7 @@ typedef struct { } lzma_length_decoder; -struct lzma_coder_s { +typedef struct { /////////////////// // Probabilities // /////////////////// @@ -277,14 +277,16 @@ struct lzma_coder_s { /// If decoding a literal: match byte. /// If decoding a match: length of the match. uint32_t len; -}; +} lzma_lzma1_decoder; static lzma_ret -lzma_decode(lzma_coder *restrict coder, lzma_dict *restrict dictptr, +lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size) { + lzma_lzma1_decoder *restrict coder = coder_ptr; + //////////////////// // Initialization // //////////////////// @@ -840,23 +842,17 @@ out: static void -lzma_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size) +lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size) { + lzma_lzma1_decoder *coder = coder_ptr; coder->uncompressed_size = uncompressed_size; } -/* -extern void -lzma_lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size) -{ - // This is hack. - (*(lzma_coder **)(coder))->uncompressed_size = uncompressed_size; -} -*/ static void -lzma_decoder_reset(lzma_coder *coder, const void *opt) +lzma_decoder_reset(void *coder_ptr, const void *opt) { + lzma_lzma1_decoder *coder = coder_ptr; const lzma_options_lzma *options = opt; // NOTE: We assume that lc/lp/pb are valid since they were @@ -941,7 +937,7 @@ lzma_lzma_decoder_create(lzma_lz_decoder *lz, const lzma_allocator *allocator, const void *opt, lzma_lz_options *lz_options) { if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); + lz->coder = lzma_alloc(sizeof(lzma_lzma1_decoder), allocator); if (lz->coder == NULL) return LZMA_MEM_ERROR; @@ -1014,7 +1010,8 @@ extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options) { const lzma_options_lzma *const opt = options; - return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size); + return sizeof(lzma_lzma1_decoder) + + lzma_lz_decoder_memusage(opt->dict_size); } diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder.c b/contrib/xz/src/liblzma/lzma/lzma_encoder.c index 4c5f99c3823d..ba9ce6989c01 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder.c +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder.c @@ -43,7 +43,7 @@ literal_matched(lzma_range_encoder *rc, probability *subcoder, static inline void -literal(lzma_coder *coder, lzma_mf *mf, uint32_t position) +literal(lzma_lzma1_encoder *coder, lzma_mf *mf, uint32_t position) { // Locate the literal byte to be encoded and the subcoder. const uint8_t cur_byte = mf->buffer[ @@ -140,7 +140,7 @@ length(lzma_range_encoder *rc, lzma_length_encoder *lc, /////////// static inline void -match(lzma_coder *coder, const uint32_t pos_state, +match(lzma_lzma1_encoder *coder, const uint32_t pos_state, const uint32_t distance, const uint32_t len) { update_match(coder->state); @@ -187,7 +187,7 @@ match(lzma_coder *coder, const uint32_t pos_state, //////////////////// static inline void -rep_match(lzma_coder *coder, const uint32_t pos_state, +rep_match(lzma_lzma1_encoder *coder, const uint32_t pos_state, const uint32_t rep, const uint32_t len) { if (rep == 0) { @@ -231,7 +231,7 @@ rep_match(lzma_coder *coder, const uint32_t pos_state, ////////// static void -encode_symbol(lzma_coder *coder, lzma_mf *mf, +encode_symbol(lzma_lzma1_encoder *coder, lzma_mf *mf, uint32_t back, uint32_t len, uint32_t position) { const uint32_t pos_state = position & coder->pos_mask; @@ -265,7 +265,7 @@ encode_symbol(lzma_coder *coder, lzma_mf *mf, static bool -encode_init(lzma_coder *coder, lzma_mf *mf) +encode_init(lzma_lzma1_encoder *coder, lzma_mf *mf) { assert(mf_position(mf) == 0); @@ -293,7 +293,7 @@ encode_init(lzma_coder *coder, lzma_mf *mf) static void -encode_eopm(lzma_coder *coder, uint32_t position) +encode_eopm(lzma_lzma1_encoder *coder, uint32_t position) { const uint32_t pos_state = position & coder->pos_mask; rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1); @@ -309,7 +309,7 @@ encode_eopm(lzma_coder *coder, uint32_t position) extern lzma_ret -lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, +lzma_lzma_encode(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, uint32_t limit) { @@ -402,7 +402,7 @@ lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, static lzma_ret -lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, +lzma_encode(void *coder, lzma_mf *restrict mf, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size) { @@ -473,7 +473,8 @@ length_encoder_reset(lzma_length_encoder *lencoder, extern lzma_ret -lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options) +lzma_lzma_encoder_reset(lzma_lzma1_encoder *coder, + const lzma_options_lzma *options) { if (!is_options_valid(options)) return LZMA_OPTIONS_ERROR; @@ -545,18 +546,18 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options) extern lzma_ret -lzma_lzma_encoder_create(lzma_coder **coder_ptr, +lzma_lzma_encoder_create(void **coder_ptr, const lzma_allocator *allocator, const lzma_options_lzma *options, lzma_lz_options *lz_options) { - // Allocate lzma_coder if it wasn't already allocated. + // Allocate lzma_lzma1_encoder if it wasn't already allocated. if (*coder_ptr == NULL) { - *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator); + *coder_ptr = lzma_alloc(sizeof(lzma_lzma1_encoder), allocator); if (*coder_ptr == NULL) return LZMA_MEM_ERROR; } - lzma_coder *coder = *coder_ptr; + lzma_lzma1_encoder *coder = *coder_ptr; // Set compression mode. We haven't validates the options yet, // but it's OK here, since nothing bad happens with invalid @@ -636,7 +637,7 @@ lzma_lzma_encoder_memusage(const void *options) if (lz_memusage == UINT64_MAX) return UINT64_MAX; - return (uint64_t)(sizeof(lzma_coder)) + lz_memusage; + return (uint64_t)(sizeof(lzma_lzma1_encoder)) + lz_memusage; } diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder.h b/contrib/xz/src/liblzma/lzma/lzma_encoder.h index cc9cc2f27ecb..6cfdf228bf5c 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder.h +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder.h @@ -17,6 +17,9 @@ #include "common.h" +typedef struct lzma_lzma1_encoder_s lzma_lzma1_encoder; + + extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters); @@ -36,16 +39,16 @@ extern bool lzma_lzma_lclppb_encode( /// Initializes raw LZMA encoder; this is used by LZMA2. extern lzma_ret lzma_lzma_encoder_create( - lzma_coder **coder_ptr, const lzma_allocator *allocator, + void **coder_ptr, const lzma_allocator *allocator, const lzma_options_lzma *options, lzma_lz_options *lz_options); /// Resets an already initialized LZMA encoder; this is used by LZMA2. extern lzma_ret lzma_lzma_encoder_reset( - lzma_coder *coder, const lzma_options_lzma *options); + lzma_lzma1_encoder *coder, const lzma_options_lzma *options); -extern lzma_ret lzma_lzma_encode(lzma_coder *restrict coder, +extern lzma_ret lzma_lzma_encode(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, uint32_t read_limit); diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c b/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c index 9b30347cbc42..6c53d2bd0082 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c @@ -18,7 +18,8 @@ extern void -lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf, +lzma_lzma_optimum_fast(lzma_lzma1_encoder *restrict coder, + lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res) { const uint32_t nice_len = mf->nice_len; diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c b/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c index a360579885db..59f77343ed79 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c @@ -19,7 +19,7 @@ //////////// static uint32_t -get_literal_price(const lzma_coder *const coder, const uint32_t pos, +get_literal_price(const lzma_lzma1_encoder *const coder, const uint32_t pos, const uint32_t prev_byte, const bool match_mode, uint32_t match_byte, uint32_t symbol) { @@ -65,7 +65,7 @@ get_len_price(const lzma_length_encoder *const lencoder, static inline uint32_t -get_short_rep_price(const lzma_coder *const coder, +get_short_rep_price(const lzma_lzma1_encoder *const coder, const lzma_lzma_state state, const uint32_t pos_state) { return rc_bit_0_price(coder->is_rep0[state]) @@ -74,7 +74,7 @@ get_short_rep_price(const lzma_coder *const coder, static inline uint32_t -get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index, +get_pure_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index, const lzma_lzma_state state, uint32_t pos_state) { uint32_t price; @@ -99,7 +99,7 @@ get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index, static inline uint32_t -get_rep_price(const lzma_coder *const coder, const uint32_t rep_index, +get_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index, const uint32_t len, const lzma_lzma_state state, const uint32_t pos_state) { @@ -109,7 +109,7 @@ get_rep_price(const lzma_coder *const coder, const uint32_t rep_index, static inline uint32_t -get_dist_len_price(const lzma_coder *const coder, const uint32_t dist, +get_dist_len_price(const lzma_lzma1_encoder *const coder, const uint32_t dist, const uint32_t len, const uint32_t pos_state) { const uint32_t dist_state = get_dist_state(len); @@ -130,7 +130,7 @@ get_dist_len_price(const lzma_coder *const coder, const uint32_t dist, static void -fill_dist_prices(lzma_coder *coder) +fill_dist_prices(lzma_lzma1_encoder *coder) { for (uint32_t dist_state = 0; dist_state < DIST_STATES; ++dist_state) { @@ -185,7 +185,7 @@ fill_dist_prices(lzma_coder *coder) static void -fill_align_prices(lzma_coder *coder) +fill_align_prices(lzma_lzma1_encoder *coder) { for (uint32_t i = 0; i < ALIGN_SIZE; ++i) coder->align_prices[i] = rc_bittree_reverse_price( @@ -221,7 +221,7 @@ make_short_rep(lzma_optimal *optimal) static void -backward(lzma_coder *restrict coder, uint32_t *restrict len_res, +backward(lzma_lzma1_encoder *restrict coder, uint32_t *restrict len_res, uint32_t *restrict back_res, uint32_t cur) { coder->opts_end_index = cur; @@ -269,7 +269,7 @@ backward(lzma_coder *restrict coder, uint32_t *restrict len_res, ////////// static inline uint32_t -helper1(lzma_coder *restrict coder, lzma_mf *restrict mf, +helper1(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res, uint32_t position) { @@ -441,7 +441,7 @@ helper1(lzma_coder *restrict coder, lzma_mf *restrict mf, static inline uint32_t -helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf, +helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf, uint32_t len_end, uint32_t position, const uint32_t cur, const uint32_t nice_len, const uint32_t buf_avail_full) { @@ -797,7 +797,8 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf, extern void -lzma_lzma_optimum_normal(lzma_coder *restrict coder, lzma_mf *restrict mf, +lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder, + lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res, uint32_t position) { diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder_presets.c b/contrib/xz/src/liblzma/lzma/lzma_encoder_presets.c index 8484b77444b1..711df0255296 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder_presets.c +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder_presets.c @@ -2,6 +2,7 @@ // /// \file lzma_encoder_presets.c /// \brief Encoder presets +/// \note xz needs this even when only decoding is enabled. // // Author: Lasse Collin // diff --git a/contrib/xz/src/liblzma/lzma/lzma_encoder_private.h b/contrib/xz/src/liblzma/lzma/lzma_encoder_private.h index 2f62d6cba0b7..a2da969f4958 100644 --- a/contrib/xz/src/liblzma/lzma/lzma_encoder_private.h +++ b/contrib/xz/src/liblzma/lzma/lzma_encoder_private.h @@ -69,7 +69,7 @@ typedef struct { } lzma_optimal; -struct lzma_coder_s { +struct lzma_lzma1_encoder_s { /// Range encoder lzma_range_encoder rc; @@ -138,10 +138,10 @@ struct lzma_coder_s { extern void lzma_lzma_optimum_fast( - lzma_coder *restrict coder, lzma_mf *restrict mf, + lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res); -extern void lzma_lzma_optimum_normal(lzma_coder *restrict coder, +extern void lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res, uint32_t position); diff --git a/contrib/xz/src/liblzma/simple/arm.c b/contrib/xz/src/liblzma/simple/arm.c index 258d870fead3..181d0e3b2232 100644 --- a/contrib/xz/src/liblzma/simple/arm.c +++ b/contrib/xz/src/liblzma/simple/arm.c @@ -15,7 +15,7 @@ static size_t -arm_code(lzma_simple *simple lzma_attribute((__unused__)), +arm_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { diff --git a/contrib/xz/src/liblzma/simple/armthumb.c b/contrib/xz/src/liblzma/simple/armthumb.c index 06c21e4067a5..eab4862dd76d 100644 --- a/contrib/xz/src/liblzma/simple/armthumb.c +++ b/contrib/xz/src/liblzma/simple/armthumb.c @@ -15,7 +15,7 @@ static size_t -armthumb_code(lzma_simple *simple lzma_attribute((__unused__)), +armthumb_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { diff --git a/contrib/xz/src/liblzma/simple/ia64.c b/contrib/xz/src/liblzma/simple/ia64.c index ba7249c00178..580529e80860 100644 --- a/contrib/xz/src/liblzma/simple/ia64.c +++ b/contrib/xz/src/liblzma/simple/ia64.c @@ -15,7 +15,7 @@ static size_t -ia64_code(lzma_simple *simple lzma_attribute((__unused__)), +ia64_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { diff --git a/contrib/xz/src/liblzma/simple/powerpc.c b/contrib/xz/src/liblzma/simple/powerpc.c index 46899196af50..54dfbf102878 100644 --- a/contrib/xz/src/liblzma/simple/powerpc.c +++ b/contrib/xz/src/liblzma/simple/powerpc.c @@ -15,7 +15,7 @@ static size_t -powerpc_code(lzma_simple *simple lzma_attribute((__unused__)), +powerpc_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { diff --git a/contrib/xz/src/liblzma/simple/simple_coder.c b/contrib/xz/src/liblzma/simple/simple_coder.c index dba5417b4264..13ebabc76dcc 100644 --- a/contrib/xz/src/liblzma/simple/simple_coder.c +++ b/contrib/xz/src/liblzma/simple/simple_coder.c @@ -18,7 +18,7 @@ /// Copied or encodes/decodes more data to out[]. static lzma_ret -copy_or_code(lzma_coder *coder, const lzma_allocator *allocator, +copy_or_code(lzma_simple_coder *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) @@ -55,7 +55,7 @@ copy_or_code(lzma_coder *coder, const lzma_allocator *allocator, static size_t -call_filter(lzma_coder *coder, uint8_t *buffer, size_t size) +call_filter(lzma_simple_coder *coder, uint8_t *buffer, size_t size) { const size_t filtered = coder->filter(coder->simple, coder->now_pos, coder->is_encoder, @@ -66,11 +66,13 @@ call_filter(lzma_coder *coder, uint8_t *buffer, size_t size) static lzma_ret -simple_code(lzma_coder *coder, const lzma_allocator *allocator, +simple_code(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) { + lzma_simple_coder *coder = coder_ptr; + // TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it // in cases when the filter is able to filter everything. With most // simple filters it can be done at offset that is a multiple of 2, @@ -198,8 +200,9 @@ simple_code(lzma_coder *coder, const lzma_allocator *allocator, static void -simple_coder_end(lzma_coder *coder, const lzma_allocator *allocator) +simple_coder_end(void *coder_ptr, const lzma_allocator *allocator) { + lzma_simple_coder *coder = coder_ptr; lzma_next_end(&coder->next, allocator); lzma_free(coder->simple, allocator); lzma_free(coder, allocator); @@ -208,10 +211,12 @@ simple_coder_end(lzma_coder *coder, const lzma_allocator *allocator) static lzma_ret -simple_coder_update(lzma_coder *coder, const lzma_allocator *allocator, +simple_coder_update(void *coder_ptr, const lzma_allocator *allocator, const lzma_filter *filters_null lzma_attribute((__unused__)), const lzma_filter *reversed_filters) { + lzma_simple_coder *coder = coder_ptr; + // No update support, just call the next filter in the chain. return lzma_next_filter_update( &coder->next, allocator, reversed_filters + 1); @@ -221,57 +226,57 @@ simple_coder_update(lzma_coder *coder, const lzma_allocator *allocator, extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters, - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, + size_t (*filter)(void *simple, uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size), size_t simple_size, size_t unfiltered_max, uint32_t alignment, bool is_encoder) { - // Allocate memory for the lzma_coder structure if needed. - if (next->coder == NULL) { + // Allocate memory for the lzma_simple_coder structure if needed. + lzma_simple_coder *coder = next->coder; + if (coder == NULL) { // Here we allocate space also for the temporary buffer. We // need twice the size of unfiltered_max, because then it // is always possible to filter at least unfiltered_max bytes // more data in coder->buffer[] if it can be filled completely. - next->coder = lzma_alloc(sizeof(lzma_coder) + coder = lzma_alloc(sizeof(lzma_simple_coder) + 2 * unfiltered_max, allocator); - if (next->coder == NULL) + if (coder == NULL) return LZMA_MEM_ERROR; + next->coder = coder; next->code = &simple_code; next->end = &simple_coder_end; next->update = &simple_coder_update; - next->coder->next = LZMA_NEXT_CODER_INIT; - next->coder->filter = filter; - next->coder->allocated = 2 * unfiltered_max; + coder->next = LZMA_NEXT_CODER_INIT; + coder->filter = filter; + coder->allocated = 2 * unfiltered_max; // Allocate memory for filter-specific data structure. if (simple_size > 0) { - next->coder->simple = lzma_alloc( - simple_size, allocator); - if (next->coder->simple == NULL) + coder->simple = lzma_alloc(simple_size, allocator); + if (coder->simple == NULL) return LZMA_MEM_ERROR; } else { - next->coder->simple = NULL; + coder->simple = NULL; } } if (filters[0].options != NULL) { const lzma_options_bcj *simple = filters[0].options; - next->coder->now_pos = simple->start_offset; - if (next->coder->now_pos & (alignment - 1)) + coder->now_pos = simple->start_offset; + if (coder->now_pos & (alignment - 1)) return LZMA_OPTIONS_ERROR; } else { - next->coder->now_pos = 0; + coder->now_pos = 0; } // Reset variables. - next->coder->is_encoder = is_encoder; - next->coder->end_was_reached = false; - next->coder->pos = 0; - next->coder->filtered = 0; - next->coder->size = 0; - - return lzma_next_filter_init( - &next->coder->next, allocator, filters + 1); + coder->is_encoder = is_encoder; + coder->end_was_reached = false; + coder->pos = 0; + coder->filtered = 0; + coder->size = 0; + + return lzma_next_filter_init(&coder->next, allocator, filters + 1); } diff --git a/contrib/xz/src/liblzma/simple/simple_private.h b/contrib/xz/src/liblzma/simple/simple_private.h index bb20cb419f8c..9d2c0fdd7618 100644 --- a/contrib/xz/src/liblzma/simple/simple_private.h +++ b/contrib/xz/src/liblzma/simple/simple_private.h @@ -16,9 +16,7 @@ #include "simple_coder.h" -typedef struct lzma_simple_s lzma_simple; - -struct lzma_coder_s { +typedef struct { /// Next filter in the chain lzma_next_coder next; @@ -33,12 +31,12 @@ struct lzma_coder_s { /// Pointer to filter-specific function, which does /// the actual filtering. - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, + size_t (*filter)(void *simple, uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size); /// Pointer to filter-specific data, or NULL if filter doesn't need /// any extra data. - lzma_simple *simple; + void *simple; /// The lowest 32 bits of the current position in the data. Most /// filters need this to do conversions between absolute and relative @@ -62,13 +60,13 @@ struct lzma_coder_s { /// Temporary buffer uint8_t buffer[]; -}; +} lzma_simple_coder; extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters, - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, + size_t (*filter)(void *simple, uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size), size_t simple_size, size_t unfiltered_max, uint32_t alignment, bool is_encoder); diff --git a/contrib/xz/src/liblzma/simple/sparc.c b/contrib/xz/src/liblzma/simple/sparc.c index 53ee49d154f1..74b2655f36ea 100644 --- a/contrib/xz/src/liblzma/simple/sparc.c +++ b/contrib/xz/src/liblzma/simple/sparc.c @@ -15,7 +15,7 @@ static size_t -sparc_code(lzma_simple *simple lzma_attribute((__unused__)), +sparc_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { diff --git a/contrib/xz/src/liblzma/simple/x86.c b/contrib/xz/src/liblzma/simple/x86.c index 3b2b4f852067..0b14807e900c 100644 --- a/contrib/xz/src/liblzma/simple/x86.c +++ b/contrib/xz/src/liblzma/simple/x86.c @@ -17,14 +17,14 @@ #define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) -struct lzma_simple_s { +typedef struct { uint32_t prev_mask; uint32_t prev_pos; -}; +} lzma_simple_x86; static size_t -x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder, +x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { static const bool MASK_TO_ALLOWED_STATUS[8] @@ -33,6 +33,7 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder, static const uint32_t MASK_TO_BIT_NUMBER[8] = { 0, 1, 2, 2, 3, 3, 3, 3 }; + lzma_simple_x86 *simple = simple_ptr; uint32_t prev_mask = simple->prev_mask; uint32_t prev_pos = simple->prev_pos; @@ -127,11 +128,13 @@ x86_coder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters, bool is_encoder) { const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters, - &x86_code, sizeof(lzma_simple), 5, 1, is_encoder); + &x86_code, sizeof(lzma_simple_x86), 5, 1, is_encoder); if (ret == LZMA_OK) { - next->coder->simple->prev_mask = 0; - next->coder->simple->prev_pos = (uint32_t)(-5); + lzma_simple_coder *coder = next->coder; + lzma_simple_x86 *simple = coder->simple; + simple->prev_mask = 0; + simple->prev_pos = (uint32_t)(-5); } return ret; diff --git a/contrib/xz/src/xz/args.c b/contrib/xz/src/xz/args.c index 041c80073e6d..341f29e1b0e9 100644 --- a/contrib/xz/src/xz/args.c +++ b/contrib/xz/src/xz/args.c @@ -635,6 +635,22 @@ args_parse(args_info *args, int argc, char **argv) // Then from the command line parse_real(args, argc, argv); + // If encoder or decoder support was omitted at build time, + // show an error now so that the rest of the code can rely on + // that whatever is in opt_mode is also supported. +#ifndef HAVE_ENCODERS + if (opt_mode == MODE_COMPRESS) + message_fatal(_("Compression support was disabled " + "at build time")); +#endif +#ifndef HAVE_DECODERS + // Even MODE_LIST cannot work without decoder support so MODE_COMPRESS + // is the only valid choice. + if (opt_mode != MODE_COMPRESS) + message_fatal(_("Decompression support was disabled " + "at build time")); +#endif + // Never remove the source file when the destination is not on disk. // In test mode the data is written nowhere, but setting opt_stdout // will make the rest of the code behave well. diff --git a/contrib/xz/src/xz/coder.c b/contrib/xz/src/xz/coder.c index a94bdb83266f..3c6a01cbbdbe 100644 --- a/contrib/xz/src/xz/coder.c +++ b/contrib/xz/src/xz/coder.c @@ -51,7 +51,7 @@ static lzma_check check; /// This becomes false if the --check=CHECK option is used. static bool check_default = true; -#ifdef MYTHREAD_ENABLED +#if defined(HAVE_ENCODERS) && defined(MYTHREAD_ENABLED) static lzma_mt mt_options = { .flags = 0, .timeout = 300, @@ -221,9 +221,10 @@ coder_set_compression_settings(void) // Get the memory usage. Note that if --format=raw was used, // we can be decompressing. const uint64_t memory_limit = hardware_memlimit_get(opt_mode); - uint64_t memory_usage; + uint64_t memory_usage = UINT64_MAX; if (opt_mode == MODE_COMPRESS) { -#ifdef MYTHREAD_ENABLED +#ifdef HAVE_ENCODERS +# ifdef MYTHREAD_ENABLED if (opt_format == FORMAT_XZ && hardware_threads_get() > 1) { mt_options.threads = hardware_threads_get(); mt_options.block_size = opt_block_size; @@ -235,12 +236,15 @@ coder_set_compression_settings(void) " threads."), mt_options.threads); } else -#endif +# endif { memory_usage = lzma_raw_encoder_memusage(filters); } +#endif } else { +#ifdef HAVE_DECODERS memory_usage = lzma_raw_decoder_memusage(filters); +#endif } if (memory_usage == UINT64_MAX) @@ -248,7 +252,11 @@ coder_set_compression_settings(void) // Print memory usage info before possible dictionary // size auto-adjusting. + // + // NOTE: If only encoder support was built, we cannot show the + // what the decoder memory usage will be. message_mem_needed(V_DEBUG, memory_usage); +#ifdef HAVE_DECODERS if (opt_mode == MODE_COMPRESS) { const uint64_t decmem = lzma_raw_decoder_memusage(filters); if (decmem != UINT64_MAX) @@ -256,6 +264,7 @@ coder_set_compression_settings(void) "%s MiB of memory."), uint64_to_str( round_up_to_mib(decmem), 0)); } +#endif if (memory_usage <= memory_limit) return; @@ -268,7 +277,8 @@ coder_set_compression_settings(void) assert(opt_mode == MODE_COMPRESS); -#ifdef MYTHREAD_ENABLED +#ifdef HAVE_ENCODERS +# ifdef MYTHREAD_ENABLED if (opt_format == FORMAT_XZ && mt_options.threads > 1) { // Try to reduce the number of threads before // adjusting the compression settings down. @@ -295,7 +305,7 @@ coder_set_compression_settings(void) uint64_to_str(round_up_to_mib( memory_limit), 2)); } -#endif +# endif if (memory_usage <= memory_limit) return; @@ -349,11 +359,13 @@ coder_set_compression_settings(void) uint64_to_str(orig_dict_size >> 20, 0), uint64_to_str(opt->dict_size >> 20, 1), uint64_to_str(round_up_to_mib(memory_limit), 2)); +#endif return; } +#ifdef HAVE_DECODERS /// Return true if the data in in_buf seems to be in the .xz format. static bool is_format_xz(void) @@ -411,6 +423,7 @@ is_format_lzma(void) return true; } +#endif /// Detect the input file type (for now, this done only when decompressing), @@ -424,6 +437,7 @@ coder_init(file_pair *pair) lzma_ret ret = LZMA_PROG_ERROR; if (opt_mode == MODE_COMPRESS) { +#ifdef HAVE_ENCODERS switch (opt_format) { case FORMAT_AUTO: // args.c ensures this. @@ -431,12 +445,12 @@ coder_init(file_pair *pair) break; case FORMAT_XZ: -#ifdef MYTHREAD_ENABLED +# ifdef MYTHREAD_ENABLED if (hardware_threads_get() > 1) ret = lzma_stream_encoder_mt( &strm, &mt_options); else -#endif +# endif ret = lzma_stream_encoder( &strm, filters, check); break; @@ -449,7 +463,9 @@ coder_init(file_pair *pair) ret = lzma_raw_encoder(&strm, filters); break; } +#endif } else { +#ifdef HAVE_DECODERS uint32_t flags = 0; // It seems silly to warn about unsupported check if the @@ -531,6 +547,7 @@ coder_init(file_pair *pair) strm.avail_out = 0; ret = lzma_code(&strm, LZMA_RUN); } +#endif } if (ret != LZMA_OK) { diff --git a/contrib/xz/src/xz/file_io.c b/contrib/xz/src/xz/file_io.c index 9bd515ddc894..c01f4e8bb99d 100644 --- a/contrib/xz/src/xz/file_io.c +++ b/contrib/xz/src/xz/file_io.c @@ -23,10 +23,20 @@ static bool warn_fchown; #if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMES) # include <sys/time.h> +#elif defined(HAVE__FUTIME) +# include <sys/utime.h> #elif defined(HAVE_UTIME) # include <utime.h> #endif +#ifdef HAVE_CAPSICUM +# ifdef HAVE_SYS_CAPSICUM_H +# include <sys/capsicum.h> +# else +# include <sys/capability.h> +# endif +#endif + #include "tuklib_open_stdxxx.h" #ifndef O_BINARY @@ -37,6 +47,14 @@ static bool warn_fchown; # define O_NOCTTY 0 #endif +// Using this macro to silence a warning from gcc -Wlogical-op. +#if EAGAIN == EWOULDBLOCK +# define IS_EAGAIN_OR_EWOULDBLOCK(e) ((e) == EAGAIN) +#else +# define IS_EAGAIN_OR_EWOULDBLOCK(e) \ + ((e) == EAGAIN || (e) == EWOULDBLOCK) +#endif + typedef enum { IO_WAIT_MORE, // Reading or writing is possible. @@ -48,6 +66,11 @@ typedef enum { /// If true, try to create sparse files when decompressing. static bool try_sparse = true; +#ifdef ENABLE_SANDBOX +/// True if the conditions for sandboxing (described in main()) have been met. +static bool sandbox_allowed = false; +#endif + #ifndef TUKLIB_DOSLIKE /// File status flags of standard input. This is used by io_open_src() /// and io_close_src(). @@ -132,6 +155,73 @@ io_no_sparse(void) } +#ifdef ENABLE_SANDBOX +extern void +io_allow_sandbox(void) +{ + sandbox_allowed = true; + return; +} + + +/// Enables operating-system-specific sandbox if it is possible. +/// src_fd is the file descriptor of the input file. +static void +io_sandbox_enter(int src_fd) +{ + if (!sandbox_allowed) { + message(V_DEBUG, _("Sandbox is disabled due " + "to incompatible command line arguments")); + return; + } + + const char dummy_str[] = "x"; + + // Try to ensure that both libc and xz locale files have been + // loaded when NLS is enabled. + snprintf(NULL, 0, "%s%s", _(dummy_str), strerror(EINVAL)); + + // Try to ensure that iconv data files needed for handling multibyte + // characters have been loaded. This is needed at least with glibc. + tuklib_mbstr_width(dummy_str, NULL); + +#ifdef HAVE_CAPSICUM + // Capsicum needs FreeBSD 10.0 or later. + cap_rights_t rights; + + if (cap_rights_limit(src_fd, cap_rights_init(&rights, + CAP_EVENT, CAP_FCNTL, CAP_LOOKUP, CAP_READ, CAP_SEEK))) + goto error; + + if (cap_rights_limit(STDOUT_FILENO, cap_rights_init(&rights, + CAP_EVENT, CAP_FCNTL, CAP_FSTAT, CAP_LOOKUP, + CAP_WRITE, CAP_SEEK))) + goto error; + + if (cap_rights_limit(user_abort_pipe[0], cap_rights_init(&rights, + CAP_EVENT))) + goto error; + + if (cap_rights_limit(user_abort_pipe[1], cap_rights_init(&rights, + CAP_WRITE))) + goto error; + + if (cap_enter()) + goto error; + +#else +# error ENABLE_SANDBOX is defined but no sandboxing method was found. +#endif + + message(V_DEBUG, _("Sandbox was successfully enabled")); + return; + +error: + message(V_DEBUG, _("Failed to enable the sandbox")); +} +#endif // ENABLE_SANDBOX + + #ifndef TUKLIB_DOSLIKE /// \brief Waits for input or output to become available or for a signal /// @@ -369,6 +459,22 @@ io_copy_attrs(const file_pair *pair) (void)utimes(pair->dest_name, tv); # endif +#elif defined(HAVE__FUTIME) + // Use one-second precision with Windows-specific _futime(). + // We could use utime() too except that for some reason the + // timestamp will get reset at close(). With _futime() it works. + // This struct cannot be const as _futime() takes a non-const pointer. + struct _utimbuf buf = { + .actime = pair->src_st.st_atime, + .modtime = pair->src_st.st_mtime, + }; + + // Avoid warnings. + (void)atime_nsec; + (void)mtime_nsec; + + (void)_futime(pair->dest_fd, &buf); + #elif defined(HAVE_UTIME) // Use one-second precision. utime() doesn't support using file // descriptor either. Some systems have broken utime() prototype @@ -649,6 +755,11 @@ io_open_src(const char *src_name) const bool error = io_open_src_real(&pair); signals_unblock(); +#ifdef ENABLE_SANDBOX + if (!error) + io_sandbox_enter(pair.src_fd); +#endif + return error ? NULL : &pair; } @@ -675,23 +786,22 @@ io_close_src(file_pair *pair, bool success) #endif if (pair->src_fd != STDIN_FILENO && pair->src_fd != -1) { -#ifdef TUKLIB_DOSLIKE + // Close the file before possibly unlinking it. On DOS-like + // systems this is always required since unlinking will fail + // if the file is open. On POSIX systems it usually works + // to unlink open files, but in some cases it doesn't and + // one gets EBUSY in errno. + // + // xz 5.2.2 and older unlinked the file before closing it + // (except on DOS-like systems). The old code didn't handle + // EBUSY and could fail e.g. on some CIFS shares. The + // advantage of unlinking before closing is negligible + // (avoids a race between close() and stat()/lstat() and + // unlink()), so let's keep this simple. (void)close(pair->src_fd); -#endif - // If we are going to unlink(), do it before closing the file. - // This way there's no risk that someone replaces the file and - // happens to get same inode number, which would make us - // unlink() wrong file. - // - // NOTE: DOS-like systems are an exception to this, because - // they don't allow unlinking files that are open. *sigh* if (success && !opt_keep_original) io_unlink(pair->src_name, &pair->src_st); - -#ifndef TUKLIB_DOSLIKE - (void)close(pair->src_fd); -#endif } return; @@ -1018,7 +1128,7 @@ io_read(file_pair *pair, io_buf *buf_union, size_t size) } #ifndef TUKLIB_DOSLIKE - if (errno == EAGAIN || errno == EWOULDBLOCK) { + if (IS_EAGAIN_OR_EWOULDBLOCK(errno)) { const io_wait_ret ret = io_wait(pair, mytime_get_flush_timeout(), true); @@ -1106,7 +1216,7 @@ io_write_buf(file_pair *pair, const uint8_t *buf, size_t size) } #ifndef TUKLIB_DOSLIKE - if (errno == EAGAIN || errno == EWOULDBLOCK) { + if (IS_EAGAIN_OR_EWOULDBLOCK(errno)) { if (io_wait(pair, -1, false) == IO_WAIT_MORE) continue; diff --git a/contrib/xz/src/xz/file_io.h b/contrib/xz/src/xz/file_io.h index 2de3379238d6..6722aef84092 100644 --- a/contrib/xz/src/xz/file_io.h +++ b/contrib/xz/src/xz/file_io.h @@ -80,6 +80,12 @@ extern void io_write_to_user_abort_pipe(void); extern void io_no_sparse(void); +#ifdef ENABLE_SANDBOX +/// \brief main() calls this if conditions for sandboxing have been met. +extern void io_allow_sandbox(void); +#endif + + /// \brief Open the source file extern file_pair *io_open_src(const char *src_name); diff --git a/contrib/xz/src/xz/main.c b/contrib/xz/src/xz/main.c index 5608229d54c5..af550c4585d9 100644 --- a/contrib/xz/src/xz/main.c +++ b/contrib/xz/src/xz/main.c @@ -205,10 +205,31 @@ main(int argc, char **argv) if (opt_mode != MODE_LIST) signals_init(); +#ifdef ENABLE_SANDBOX + // Set a flag that sandboxing is allowed if all these are true: + // - --files or --files0 wasn't used. + // - There is exactly one input file or we are reading from stdin. + // - We won't create any files: output goes to stdout or --test + // or --list was used. Note that --test implies opt_stdout = true + // but --list doesn't. + // + // This is obviously not ideal but it was easy to implement and + // it covers the most common use cases. + // + // TODO: Make sandboxing work for other situations too. + if (args.files_name == NULL && args.arg_count == 1 + && (opt_stdout || strcmp("-", args.arg_names[0]) == 0 + || opt_mode == MODE_LIST)) + io_allow_sandbox(); +#endif + // coder_run() handles compression, decompression, and testing. // list_file() is for --list. - void (*run)(const char *filename) = opt_mode == MODE_LIST - ? &list_file : &coder_run; + void (*run)(const char *filename) = &coder_run; +#ifdef HAVE_DECODERS + if (opt_mode == MODE_LIST) + run = &list_file; +#endif // Process the files given on the command line. Note that if no names // were given, args_parse() gave us a fake "-" filename. @@ -267,6 +288,7 @@ main(int argc, char **argv) (void)fclose(args.files_file); } +#ifdef HAVE_DECODERS // All files have now been handled. If in --list mode, display // the totals before exiting. We don't have signal handlers // enabled in --list mode, so we don't need to check user_abort. @@ -274,6 +296,7 @@ main(int argc, char **argv) assert(!user_abort); list_totals(); } +#endif #ifndef NDEBUG coder_free(); diff --git a/contrib/xz/src/xz/private.h b/contrib/xz/src/xz/private.h index 4acfa8dc4558..e61563ac72af 100644 --- a/contrib/xz/src/xz/private.h +++ b/contrib/xz/src/xz/private.h @@ -45,6 +45,10 @@ # define STDERR_FILENO (fileno(stderr)) #endif +#ifdef HAVE_CAPSICUM +# define ENABLE_SANDBOX 1 +#endif + #include "main.h" #include "mytime.h" #include "coder.h" @@ -56,4 +60,7 @@ #include "signals.h" #include "suffix.h" #include "util.h" -#include "list.h" + +#ifdef HAVE_DECODERS +# include "list.h" +#endif |