]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
15 months agoliblzma: Move a few __attribute__ uses in function declarations.
Lasse Collin [Mon, 11 Sep 2023 15:47:26 +0000 (18:47 +0300)] 
liblzma: Move a few __attribute__ uses in function declarations.

The API headers have many attributes but these were left
as is for now.

(cherry picked from commit e3478ae4f36cd06522a2fef023860893f068434d)

15 months agoxz, xzdec, lzmainfo: Use tuklib_attr_noreturn.
Lasse Collin [Mon, 11 Sep 2023 16:03:35 +0000 (19:03 +0300)] 
xz, xzdec, lzmainfo: Use tuklib_attr_noreturn.

For compatibility with C23's [[noreturn]], tuklib_attr_noreturn
must be at the beginning of declaration (before "extern" or
"static", and even before any GNU C's __attribute__).

This commit also moves all other function attributes to
the beginning of function declarations. "extern" is kept
at the beginning of a line so the attributes are listed on
separate lines before "extern" or "static".

(cherry picked from commit b71b8922ef3971e5ccffd1e213888d44abe21d11)

15 months agoRemove incorrect uses of __attribute__((__malloc__)).
Lasse Collin [Mon, 11 Sep 2023 15:53:31 +0000 (18:53 +0300)] 
Remove incorrect uses of __attribute__((__malloc__)).

xrealloc() is obviously incorrect, modern GCC docs even
mention realloc() as an example where this attribute
cannot be used.

liblzma's lzma_alloc() and lzma_alloc_zero() would be
correct uses most of the time but custom allocators
may use a memory pool or otherwise hold the pointer
so aliasing issues could happen in theory.

The xstrdup() case likely was correct but I removed it anyway.
Now there are no __malloc__ attributes left in the code.
The allocations aren't in hot paths so this should make
no practical difference.

(cherry picked from commit 359e5c6cb128dab64ea6070d21d1c240f96cea6b)

15 months agoCMake: Fix time.h checks not running on second CMake run.
Jia Tan [Tue, 12 Sep 2023 14:36:12 +0000 (22:36 +0800)] 
CMake: Fix time.h checks not running on second CMake run.

If CMake was configured more than once, HAVE_CLOCK_GETTIME and
HAVE_CLOCK_MONOTONIC would not be set as compile definitions. The check
for librt being needed to provide HAVE_CLOCK_GETTIME was also
simplified.

(cherry picked from commit a70e96d2da761b8b3a77bf14e08002d871e5950b)

15 months agoxz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.
Lasse Collin [Thu, 31 Aug 2023 15:14:43 +0000 (18:14 +0300)] 
xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.

SSIZE_MAX isn't readily available on MSVC. Removing it means
that there is one thing less to worry when porting to MSVC.

(cherry picked from commit ef71f83973a20cc28a3221f85681922026ea33f5)

15 months agoUpdate THANKS.
Jia Tan [Mon, 28 Aug 2023 13:52:54 +0000 (21:52 +0800)] 
Update THANKS.

(cherry picked from commit 4b23b84b89e39a5117e16f66c3b01db4f08ed3e7)

15 months agoliblzma: Update assert in vli_ceil4().
Jia Tan [Mon, 28 Aug 2023 13:50:16 +0000 (21:50 +0800)] 
liblzma: Update assert in vli_ceil4().

The argument to vli_ceil4() should always guarantee the return value
is also a valid lzma_vli. Thus the highest three valid lzma_vli values
are invalid arguments. All uses of the function ensure this so the
assert is updated to match this.

(cherry picked from commit 773f1e8622cb1465df528cb16a749517650acd93)

15 months agoliblzma: Add overflow check for Unpadded size in lzma_index_append().
Jia Tan [Mon, 28 Aug 2023 13:31:25 +0000 (21:31 +0800)] 
liblzma: Add overflow check for Unpadded size in lzma_index_append().

This was not a security bug since there was no path to overflow
UINT64_MAX in lzma_index_append() or when it calls index_file_size().
The bug was discovered by a failing assert() in vli_ceil4() when called
from index_file_size() when unpadded_sum (the sum of the compressed size
of current Stream and the unpadded_size parameter) exceeds LZMA_VLI_MAX.

Previously, the unpadded_size parameter was checked to be not greater
than UNPADDED_SIZE_MAX, but no check was done once compressed_base was
added.

This could not have caused an integer overflow in index_file_size() when
called by lzma_index_append(). The calculation for file_size breaks down
into the sum of:

- Compressed base from all previous Streams
- 2 * LZMA_STREAM_HEADER_SIZE (size of the current Streams header and
  footer)
- stream_padding (can be set by lzma_index_stream_padding())
- Compressed base from the current Stream
- Unpadded size (parameter to lzma_index_append())

The sum of everything except for Unpadded size must be less than
LZMA_VLI_MAX. This is guarenteed by overflow checks in the functions
that can set these values including lzma_index_stream_padding(),
lzma_index_append(), and lzma_index_cat(). The maximum value for
Unpadded size is enforced by lzma_index_append() to be less than or
equal UNPADDED_SIZE_MAX. Thus, the sum cannot exceed UINT64_MAX since
LZMA_VLI_MAX is half of UINT64_MAX.

Thanks to Joona Kannisto for reporting this.

(cherry picked from commit 68bda971bb8b666a009331455fcedb4e18d837a4)

15 months agomythread.h: Fix typo error in Vista threads mythread_once().
Jamaika1 [Tue, 8 Aug 2023 12:07:59 +0000 (14:07 +0200)] 
mythread.h: Fix typo error in Vista threads mythread_once().

The "once_" variable was accidentally referred to as just "once". This
prevented building with Vista threads when
HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR was not defined.

(cherry picked from commit c0c0cd4a483a672b66a13761583bc4f84d86d501)

15 months agobuild-aux/manconv.sh: Fix US-ASCII and UTF-8 output.
Lasse Collin [Wed, 2 Aug 2023 12:19:43 +0000 (15:19 +0300)] 
build-aux/manconv.sh: Fix US-ASCII and UTF-8 output.

groff defaults to SGR escapes. Using -P-c passes -c to grotty
which restores the old behavior. Perhaps there is a better way to
get pure plain text output but this works for now.

(cherry picked from commit 6a1093c0004c42eeaef312456c295671496dd67a)

15 months agoliblzma: Prevent an empty translation unit in Windows builds.
Jia Tan [Mon, 24 Jul 2023 13:43:44 +0000 (21:43 +0800)] 
liblzma: Prevent an empty translation unit in Windows builds.

To workaround Automake lacking Windows resource compiler support, an
empty source file is compiled to overwrite the resource files for static
library builds. Translation units without an external declaration are
not allowed by the C standard and result in a warning when used with
-Wempty-translation-unit (Clang) or -pedantic (GCC).

(cherry picked from commit 19899340cf74d98304f9f5b726c72e85c7017d72)

15 months agoliblzma: Tweak #if condition in memcmplen.h.
Lasse Collin [Tue, 18 Jul 2023 10:57:54 +0000 (13:57 +0300)] 
liblzma: Tweak #if condition in memcmplen.h.

Maybe ICC always #defines _MSC_VER on Windows but now
it's very clear which code will get used.

(cherry picked from commit b406828a6dfd3caa4f77efe3ff3e3eea263eee62)

15 months agoliblzma: Omit unnecessary parenthesis in a preprocessor directive.
Lasse Collin [Tue, 18 Jul 2023 10:49:43 +0000 (13:49 +0300)] 
liblzma: Omit unnecessary parenthesis in a preprocessor directive.

(cherry picked from commit ef4a07ad9434f81417395f6fe0bb331e027a703b)

15 months agoliblzma: Prevent warning for MSYS2 Windows build.
Jia Tan [Wed, 28 Jun 2023 12:22:38 +0000 (20:22 +0800)] 
liblzma: Prevent warning for MSYS2 Windows build.

In lzma_memcmplen(), the <intrin.h> header file is only included if
_MSC_VER and _M_X64 are both defined but _BitScanForward64() was
previously used if _M_X64 was defined. GCC for MSYS2 defines _M_X64 but
not _MSC_VER so _BitScanForward64() was used without including
<intrin.h>.

Now, lzma_memcmplen() will use __builtin_ctzll() for MSYS2 GCC builds as
expected.

(cherry picked from commit 64ee0caaea06654b28afaee850fb187a11bf9cb2)

15 months agoliblzma: Prevent uninitialzed warning in mt stream encoder.
Jia Tan [Wed, 28 Jun 2023 12:31:11 +0000 (20:31 +0800)] 
liblzma: Prevent uninitialzed warning in mt stream encoder.

This change only impacts the compiler warning since it was impossible
for the wait_abs struct in stream_encode_mt() to be used before it was
initialized since mythread_condtime_set() will always be called before
mythread_cond_timedwait().

Since the mythread.h code is different between the POSIX and
Windows versions, this warning was only present on Windows builds.

Thanks to Arthur S for reporting the warning and providing an initial
patch.

(cherry picked from commit 1155471651ad456c5f90aee6435931fae65682bf)

15 months agoUpdate THANKS.
Jia Tan [Tue, 6 Jun 2023 16:10:38 +0000 (00:10 +0800)] 
Update THANKS.

(cherry picked from commit 62dd1c9bf0c66679ceeebc8b99bca136ca43bcb9)

15 months agoCMake: Protects against double find_package
Benjamin Buch [Tue, 6 Jun 2023 13:32:45 +0000 (15:32 +0200)] 
CMake: Protects against double find_package

Boost iostream uses `find_package` in quiet mode and then again uses
`find_package` with required. This second call triggers a
`add_library cannot create imported target "LibLZMA::LibLZMA"
because another target with the same name already exists.`

This can simply be fixed by skipping the alias part on secondary
`find_package` runs.

(cherry picked from commit d04eb78ab3892d3678c180437dd66379efa051fd)

2 years agoBump version and soname for 5.2.12. v5.2.12
Jia Tan [Thu, 4 May 2023 11:48:19 +0000 (19:48 +0800)] 
Bump version and soname for 5.2.12.

2 years agoAdd NEWS for 5.2.12.
Jia Tan [Tue, 2 May 2023 12:39:37 +0000 (20:39 +0800)] 
Add NEWS for 5.2.12.

2 years agoTranslations: Update the Croatian translation.
Jia Tan [Thu, 4 May 2023 12:38:52 +0000 (20:38 +0800)] 
Translations: Update the Croatian translation.

2 years agotuklib_integer.h: Fix a recent copypaste error in Clang detection.
Lasse Collin [Wed, 3 May 2023 19:46:42 +0000 (22:46 +0300)] 
tuklib_integer.h: Fix a recent copypaste error in Clang detection.

Wrong line was changed in 7062348bf35c1e4cbfee00ad9fffb4a21aa6eff7.
Also, this has >= instead of == since ints larger than 32 bits would
work too even if not relevant in practice.

2 years agoUpdate THANKS.
Jia Tan [Thu, 20 Apr 2023 12:15:00 +0000 (20:15 +0800)] 
Update THANKS.

2 years agoWindows: Include <intrin.h> when needed.
Jia Tan [Wed, 19 Apr 2023 14:22:16 +0000 (22:22 +0800)] 
Windows: Include <intrin.h> when needed.

Legacy Windows did not need to #include <intrin.h> to use the MSVC
intrinsics. Newer versions likely just issue a warning, but the MSVC
documentation says to include the header file for the intrinsics we use.

GCC and Clang can "pretend" to be MSVC on Windows, so extra checks are
needed in tuklib_integer.h to only include <intrin.h> when it will is
actually needed.

2 years agotuklib_integer: Use __builtin_clz() with Clang.
Jia Tan [Wed, 19 Apr 2023 13:59:03 +0000 (21:59 +0800)] 
tuklib_integer: Use __builtin_clz() with Clang.

Clang has support for __builtin_clz(), but previously Clang would
fallback to either the MSVC intrinsic or the regular C code. This was
discovered due to a bug where a new version of Clang required the
<intrin.h> header file in order to use the MSVC intrinsics.

Thanks to Anton Kochkov for notifying us about the bug.

2 years agoliblzma: Update project maintainers in lzma.h.
Lasse Collin [Fri, 14 Apr 2023 15:42:33 +0000 (18:42 +0300)] 
liblzma: Update project maintainers in lzma.h.

AUTHORS was updated earlier, lzma.h was simply forgotten.

2 years agoliblzma: Cleans up old commented out code.
Jia Tan [Thu, 13 Apr 2023 12:45:19 +0000 (20:45 +0800)] 
liblzma: Cleans up old commented out code.

2 years agoBuild: Removes redundant check for LZMA1 filter support.
Jia Tan [Wed, 22 Mar 2023 07:42:04 +0000 (15:42 +0800)] 
Build: Removes redundant check for LZMA1 filter support.

2 years agoBuild: Add a comment that AC_PROG_CC_C99 is needed for Autoconf 2.69.
Lasse Collin [Tue, 21 Mar 2023 12:07:51 +0000 (14:07 +0200)] 
Build: Add a comment that AC_PROG_CC_C99 is needed for Autoconf 2.69.

It's obsolete in Autoconf >= 2.70 and just an alias for AC_PROG_CC
but Autoconf 2.69 requires AC_PROG_CC_C99 to get a C99 compiler.

2 years agoBuild: configure.ac: Use AS_IF and AS_CASE where required.
Lasse Collin [Tue, 21 Mar 2023 12:04:37 +0000 (14:04 +0200)] 
Build: configure.ac: Use AS_IF and AS_CASE where required.

This makes no functional difference in the generated configure
(at least with the Autotools versions I have installed) but this
change might prevent future bugs like the one that was just
fixed in the commit 5a5bd7f871818029d5ccbe189f087f591258c294.

2 years agoUpdate THANKS.
Lasse Collin [Tue, 21 Mar 2023 11:12:03 +0000 (13:12 +0200)] 
Update THANKS.

2 years agoBuild: Fix --disable-threads breaking the building of shared libs.
Lasse Collin [Tue, 21 Mar 2023 11:11:49 +0000 (13:11 +0200)] 
Build: Fix --disable-threads breaking the building of shared libs.

This is broken in the releases 5.2.6 to 5.4.2. A workaround
for these releases is to pass EGREP='grep -E' as an argument
to configure in addition to --disable-threads.

The problem appeared when m4/ax_pthread.m4 was updated in
the commit 6629ed929cc7d45a11e385f357ab58ec15e7e4ad which
introduced the use of AC_EGREP_CPP. AC_EGREP_CPP calls
AC_REQUIRE([AC_PROG_EGREP]) to set the shell variable EGREP
but this was only executed if POSIX threads were enabled.
Libtool code also has AC_REQUIRE([AC_PROG_EGREP]) but Autoconf
omits it as AC_PROG_EGREP has already been required earlier.
Thus, if not using POSIX threads, the shell variable EGREP
would be undefined in the Libtool code in configure.

ax_pthread.m4 is fine. The bug was in configure.ac which called
AX_PTHREAD conditionally in an incorrect way. Using AS_CASE
ensures that all AC_REQUIREs get always run.

Thanks to Frank Busse for reporting the bug.
Fixes: https://github.com/tukaani-project/xz/issues/45
2 years agoBump version and soname for 5.2.11. v5.2.11
Jia Tan [Sat, 18 Mar 2023 14:25:59 +0000 (22:25 +0800)] 
Bump version and soname for 5.2.11.

2 years agoAdd NEWS for 5.2.11.
Jia Tan [Sat, 18 Mar 2023 14:16:09 +0000 (22:16 +0800)] 
Add NEWS for 5.2.11.

2 years agoUpdate the copy of GNU GPLv3 from gnu.org to COPYING.GPLv3.
Lasse Collin [Sat, 18 Mar 2023 14:00:54 +0000 (16:00 +0200)] 
Update the copy of GNU GPLv3 from gnu.org to COPYING.GPLv3.

2 years agoChange a few HTTP URLs to HTTPS.
Lasse Collin [Sat, 18 Mar 2023 13:51:57 +0000 (15:51 +0200)] 
Change a few HTTP URLs to HTTPS.

The xz man page timestamp was intentionally left unchanged.

2 years agoCMake: Require that the C compiler supports C99 or a newer standard.
Lasse Collin [Mon, 27 Feb 2023 16:38:35 +0000 (18:38 +0200)] 
CMake: Require that the C compiler supports C99 or a newer standard.

Thanks to autoantwort for reporting the issue and suggesting
a different patch:
https://github.com/tukaani-project/xz/pull/42

2 years agoUpdate THANKS.
Lasse Collin [Thu, 23 Feb 2023 18:46:16 +0000 (20:46 +0200)] 
Update THANKS.

2 years agoliblzma: Avoid null pointer + 0 (undefined behavior in C).
Lasse Collin [Tue, 21 Feb 2023 20:57:10 +0000 (22:57 +0200)] 
liblzma: Avoid null pointer + 0 (undefined behavior in C).

In the C99 and C17 standards, section 6.5.6 paragraph 8 means that
adding 0 to a null pointer is undefined behavior. As of writing,
"clang -fsanitize=undefined" (Clang 15) diagnoses this. However,
I'm not aware of any compiler that would take advantage of this
when optimizing (Clang 15 included). It's good to avoid this anyway
since compilers might some day infer that pointer arithmetic implies
that the pointer is not NULL. That is, the following foo() would then
unconditionally return 0, even for foo(NULL, 0):

    void bar(char *a, char *b);

    int foo(char *a, size_t n)
    {
        bar(a, a + n);
        return a == NULL;
    }

In contrast to C, C++ explicitly allows null pointer + 0. So if
the above is compiled as C++ then there is no undefined behavior
in the foo(NULL, 0) call.

To me it seems that changing the C standard would be the sane
thing to do (just add one sentence) as it would ensure that a huge
amount of old code won't break in the future. Based on web searches
it seems that a large number of codebases (where null pointer + 0
occurs) are being fixed instead to be future-proof in case compilers
will some day optimize based on it (like making the above foo(NULL, 0)
return 0) which in the worst case will cause security bugs.

Some projects don't plan to change it. For example, gnulib and thus
many GNU tools currently require that null pointer + 0 is defined:

    https://lists.gnu.org/archive/html/bug-gnulib/2021-11/msg00000.html

    https://www.gnu.org/software/gnulib/manual/html_node/Other-portability-assumptions.html

In XZ Utils null pointer + 0 issue should be fixed after this
commit. This adds a few if-statements and thus branches to avoid
null pointer + 0. These check for size > 0 instead of ptr != NULL
because this way bugs where size > 0 && ptr == NULL will likely
get caught quickly. None of them are in hot spots so it shouldn't
matter for performance.

A little less readable version would be replacing

    ptr + offset

with

    offset != 0 ? ptr + offset : ptr

or creating a macro for it:

    #define my_ptr_add(ptr, offset) \
            ((offset) != 0 ? ((ptr) + (offset)) : (ptr))

Checking for offset != 0 instead of ptr != NULL allows GCC >= 8.1,
Clang >= 7, and Clang-based ICX to optimize it to the very same code
as ptr + offset. That is, it won't create a branch. So for hot code
this could be a good solution to avoid null pointer + 0. Unfortunately
other compilers like ICC 2021 or MSVC 19.33 (VS2022) will create a
branch from my_ptr_add().

Thanks to Marcin Kowalczyk for reporting the problem:
https://github.com/tukaani-project/xz/issues/36

2 years agoUpdate THANKS.
Lasse Collin [Fri, 17 Feb 2023 18:56:49 +0000 (20:56 +0200)] 
Update THANKS.

2 years agoBuild: Use only the generic symbol versioning on MicroBlaze.
Lasse Collin [Fri, 17 Feb 2023 18:48:28 +0000 (20:48 +0200)] 
Build: Use only the generic symbol versioning on MicroBlaze.

On MicroBlaze, GCC 12 is broken in sense that
__has_attribute(__symver__) returns true but it still doesn't
support the __symver__ attribute even though the platform is ELF
and symbol versioning is supported if using the traditional
__asm__(".symver ...") method. Avoiding the traditional method is
good because it breaks LTO (-flto) builds with GCC.

See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766

For now the only extra symbols in liblzma_linux.map are the
compatibility symbols with the patch that spread from RHEL/CentOS 7.
These require the use of __symver__ attribute or __asm__(".symver ...")
in the C code. Compatibility with the patch from CentOS 7 doesn't
seem valuable on MicroBlaze so use liblzma_generic.map on MicroBlaze
instead. It doesn't require anything special in the C code and thus
no LTO issues either.

An alternative would be to detect support for __symver__
attribute in configure.ac and CMakeLists.txt and fall back
to __asm__(".symver ...") but then LTO would be silently broken
on MicroBlaze. It sounds likely that MicroBlaze is a special
case so let's treat it as a such because that is simpler. If
a similar issue exists on some other platform too then hopefully
someone will report it and this can be reconsidered.

(This doesn't do the same fix in CMakeLists.txt. Perhaps it should
but perhaps CMake build of liblzma doesn't matter much on MicroBlaze.
The problem breaks the build so it's easy to notice and can be fixed
later.)

Thanks to Vincent Fazio for reporting the problem and proposing
a patch (in the end that solution wasn't used):
https://github.com/tukaani-project/xz/pull/32

2 years agoliblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.
Jia Tan [Sat, 21 Jan 2023 13:32:03 +0000 (21:32 +0800)] 
liblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.

LZMA_MEMLIMIT_ERROR was missing the "<" character needed to put
documentation after a member.

2 years agotuklib_physmem: Silence warning from -Wcast-function-type on MinGW-w64.
Jia Tan [Thu, 19 Jan 2023 12:35:09 +0000 (20:35 +0800)] 
tuklib_physmem: Silence warning from -Wcast-function-type on MinGW-w64.

tuklib_physmem depends on GetProcAddress() for both MSVC and MinGW-w64
to retrieve a function address. The proper way to do this is to cast the
return value to the type of function pointer retrieved. Unfortunately,
this causes a cast-function-type warning, so the best solution is to
simply ignore the warning.

2 years agoxz: Add missing comment for coder_set_compression_settings()
Jia Tan [Mon, 16 Jan 2023 13:35:45 +0000 (21:35 +0800)] 
xz: Add missing comment for coder_set_compression_settings()

2 years agoxz: Do not set compression settings with raw format in list mode.
Jia Tan [Mon, 16 Jan 2023 12:55:10 +0000 (20:55 +0800)] 
xz: Do not set compression settings with raw format in list mode.

Calling coder_set_compression_settings() in list mode with verbose mode
on caused the filter chain and memory requirements to print. This was
unnecessary since the command results in an error and not consistent
with other formats like lzma and alone.

2 years agoxz: Use ssize_t for the to-be-ignored return value from write(fd, ptr, 1).
Lasse Collin [Thu, 12 Jan 2023 04:05:58 +0000 (06:05 +0200)] 
xz: Use ssize_t for the to-be-ignored return value from write(fd, ptr, 1).

It makes no difference here as the return value fits into an int
too and it then gets ignored but this looks better.

2 years agoliblzma: Silence warnings from clang -Wconditional-uninitialized.
Lasse Collin [Thu, 12 Jan 2023 01:19:59 +0000 (03:19 +0200)] 
liblzma: Silence warnings from clang -Wconditional-uninitialized.

This is similar to 2ce4f36f179a81d0c6e182a409f363df759d1ad0.
The actual initialization of the variables is done inside
mythread_sync() macro. Clang doesn't seem to see that
the initialization code inside the macro is always executed.

2 years agoFix warnings from clang -Wdocumentation.
Lasse Collin [Thu, 12 Jan 2023 01:11:40 +0000 (03:11 +0200)] 
Fix warnings from clang -Wdocumentation.

2 years agoxz: Fix warning -Wformat-nonliteral on clang in message.c.
Jia Tan [Wed, 11 Jan 2023 14:46:48 +0000 (22:46 +0800)] 
xz: Fix warning -Wformat-nonliteral on clang in message.c.

clang and gcc differ in how they handle -Wformat-nonliteral. gcc will
allow a non-literal format string as long as the function takes its
format arguments as a va_list.

2 years agoCMake/Windows: Add a workaround for windres from GNU binutils.
Lasse Collin [Tue, 10 Jan 2023 06:50:26 +0000 (08:50 +0200)] 
CMake/Windows: Add a workaround for windres from GNU binutils.

This is combined from the following commits in the master branch:
443dfebced041adc88f10d824188eeef5b5821a9
6b117d3b1fe91eb26d533ab16a2e552f84148d47
5e34774c31d1b7509b5cb77a3be9973adec59ea0

Thanks to Iouri Kharon for the bug report, the original patch,
and testing.

2 years agoCMake: Update cmake_minimum_required from 3.13...3.16 to 3.13...3.25.
Lasse Collin [Sat, 7 Jan 2023 19:57:11 +0000 (21:57 +0200)] 
CMake: Update cmake_minimum_required from 3.13...3.16 to 3.13...3.25.

The changes listed on cmake-policies(7) for versions 3.17 to 3.25
shouldn't affect this project.

2 years agoUpdate THANKS.
Lasse Collin [Sat, 7 Jan 2023 17:50:35 +0000 (19:50 +0200)] 
Update THANKS.

2 years agoCMake: Fix a copypaste error in xzdec Windows resource file handling.
Lasse Collin [Mon, 9 Jan 2023 09:27:24 +0000 (11:27 +0200)] 
CMake: Fix a copypaste error in xzdec Windows resource file handling.

It was my mistake. Thanks to Iouri Kharon for the bug report.

2 years agoCMake/Windows: Add resource files to xz.exe and xzdec.exe.
Lasse Collin [Sat, 7 Jan 2023 17:50:03 +0000 (19:50 +0200)] 
CMake/Windows: Add resource files to xz.exe and xzdec.exe.

The command line tools cannot be built with MSVC for now but
they can be built with MinGW-w64.

Thanks to Iouri Kharon for the bug report and the original patch.

2 years agoliblzma: Update documentation for lzma_filter_encoder.
Jia Tan [Thu, 22 Dec 2022 15:14:53 +0000 (23:14 +0800)] 
liblzma: Update documentation for lzma_filter_encoder.

2 years agoDoxygen: Update .gitignore for generating docs for in source build.
Jia Cheong Tan [Tue, 20 Dec 2022 14:05:21 +0000 (22:05 +0800)] 
Doxygen: Update .gitignore for generating docs for in source build.

In source builds are not recommended, but we should still ignore
the generated artifacts.

2 years agoCMake: Update .gitignore for CMake artifacts from in source build.
Jia Tan [Fri, 16 Dec 2022 12:58:55 +0000 (20:58 +0800)] 
CMake: Update .gitignore for CMake artifacts from in source build.

In source builds are not recommended, but we can make it easier
by ignoring the generated artifacts from CMake.

2 years agoBump version and soname for 5.2.10. v5.2.10
Lasse Collin [Tue, 13 Dec 2022 11:03:20 +0000 (13:03 +0200)] 
Bump version and soname for 5.2.10.

2 years agoAdd NEWS for 5.2.10.
Lasse Collin [Tue, 13 Dec 2022 11:02:15 +0000 (13:02 +0200)] 
Add NEWS for 5.2.10.

2 years agoTests: Fix a typo in tests/files/README.
Lasse Collin [Tue, 13 Dec 2022 10:30:45 +0000 (12:30 +0200)] 
Tests: Fix a typo in tests/files/README.

2 years agoUpdate AUTHORS.
Lasse Collin [Mon, 12 Dec 2022 17:09:20 +0000 (19:09 +0200)] 
Update AUTHORS.

2 years agoxz: Make args_info.files_name a const pointer.
Lasse Collin [Thu, 8 Dec 2022 17:24:22 +0000 (19:24 +0200)] 
xz: Make args_info.files_name a const pointer.

2 years agoxz: Don't modify argv[].
Lasse Collin [Thu, 8 Dec 2022 17:18:16 +0000 (19:18 +0200)] 
xz: Don't modify argv[].

The code that parses --memlimit options and --block-list modified
the argv[] when parsing the option string from optarg. This was
visible in "ps auxf" and such and could be confusing. I didn't
understand it back in the day when I wrote that code. Now a copy
is allocated when modifiable strings are needed.

2 years agoliblzma: Check for unexpected NULL pointers in block_header_decode().
Lasse Collin [Thu, 8 Dec 2022 15:30:09 +0000 (17:30 +0200)] 
liblzma: Check for unexpected NULL pointers in block_header_decode().

The API docs gave an impression that such checks are done
but they actually weren't done. In practice it made little
difference since the calling code has a bug if these are NULL.

Thanks to Jia Tan for the original patch that checked for
block->filters == NULL.

2 years agoliblzma: Use __has_attribute(__symver__) to fix Clang detection.
Lasse Collin [Thu, 1 Dec 2022 18:04:17 +0000 (20:04 +0200)] 
liblzma: Use __has_attribute(__symver__) to fix Clang detection.

If someone sets up Clang to define __GNUC__ to 10 or greater
then symvers broke. __has_attribute is supported by such GCC
and Clang versions that don't support __symver__ so this should
be much better and simpler way to detect if __symver__ is
actually supported.

Thanks to Tomasz Gajc for the bug report.

2 years agoUpdate THANKS (sync all from master).
Lasse Collin [Mon, 12 Dec 2022 13:45:04 +0000 (15:45 +0200)] 
Update THANKS (sync all from master).

2 years agoBump version and soname for 5.2.9. v5.2.9
Lasse Collin [Wed, 30 Nov 2022 16:33:05 +0000 (18:33 +0200)] 
Bump version and soname for 5.2.9.

2 years agoAdd NEWS for 5.2.9.
Lasse Collin [Wed, 30 Nov 2022 16:31:16 +0000 (18:31 +0200)] 
Add NEWS for 5.2.9.

2 years agoChange the bug report address.
Lasse Collin [Wed, 30 Nov 2022 16:08:34 +0000 (18:08 +0200)] 
Change the bug report address.

It forwards to me and Jia Tan.

Also update the IRC reference in README as #tukaani was moved
to Libera Chat long ago.

2 years agoUpdate to HTTPS URLs in AUTHORS.
Lasse Collin [Wed, 30 Nov 2022 15:38:32 +0000 (17:38 +0200)] 
Update to HTTPS URLs in AUTHORS.

2 years agoliblzma: Remove two FIXME comments.
Lasse Collin [Sat, 26 Nov 2022 23:03:16 +0000 (01:03 +0200)] 
liblzma: Remove two FIXME comments.

2 years agoBuild: Don't put GNU/Linux-specific symbol versions into static liblzma.
Lasse Collin [Thu, 24 Nov 2022 12:52:44 +0000 (14:52 +0200)] 
Build: Don't put GNU/Linux-specific symbol versions into static liblzma.

It not only makes no sense to put symbol versions into a static library
but it can also cause breakage.

By default Libtool #defines PIC if building a shared library and
doesn't define it for static libraries. This is documented in the
Libtool manual. It can be overriden using --with-pic or --without-pic.
configure.ac detects if --with-pic or --without-pic is used and then
gives an error if neither --disable-shared nor --disable-static was
used at the same time. Thus, in normal situations it works to build
both shared and static library at the same time on GNU/Linux,
only --with-pic or --without-pic requires that only one type of
library is built.

Thanks to John Paul Adrian Glaubitz from Debian for reporting
the problem that occurred on ia64:
https://www.mail-archive.com/xz-devel@tukaani.org/msg00610.html

2 years agoCMake: Don't use symbol versioning with static library.
Lasse Collin [Wed, 23 Nov 2022 22:02:31 +0000 (00:02 +0200)] 
CMake: Don't use symbol versioning with static library.

2 years agoliblzma: Fix another invalid free() after memory allocation failure.
Lasse Collin [Wed, 23 Nov 2022 23:26:37 +0000 (01:26 +0200)] 
liblzma: Fix another invalid free() after memory allocation failure.

This time it can happen when lzma_stream_encoder_mt() is used
to reinitialize an existing multi-threaded Stream encoder
and one of 1-4 tiny allocations in lzma_filters_copy() fail.

It's very similar to the previous bug
10430fbf3820dafd4eafd38ec8be161a6978ed2b, happening with
an array of lzma_filter structures whose old options are freed
but the replacement never arrives due to a memory allocation
failure in lzma_filters_copy().

2 years agoliblzma: Add support for LZMA_SYNC_FLUSH in the Block encoder.
Jia Tan [Thu, 5 May 2022 12:53:42 +0000 (20:53 +0800)] 
liblzma: Add support for LZMA_SYNC_FLUSH in the Block encoder.

The documentation mentions that lzma_block_encoder() supports
LZMA_SYNC_FLUSH but it was never added to supported_actions[]
in the internal structure. Because of this, LZMA_SYNC_FLUSH could
not be used with the Block encoder unless it was the next coder
after something like stream_encoder() or stream_encoder_mt().

2 years agoliblzma: Add lzma_attr_warn_unused_result to lzma_filters_copy().
Lasse Collin [Wed, 23 Nov 2022 19:55:22 +0000 (21:55 +0200)] 
liblzma: Add lzma_attr_warn_unused_result to lzma_filters_copy().

2 years agoliblzma: Fix invalid free() after memory allocation failure.
Lasse Collin [Wed, 23 Nov 2022 19:26:21 +0000 (21:26 +0200)] 
liblzma: Fix invalid free() after memory allocation failure.

The bug was in the single-threaded .xz Stream encoder
in the code that is used for both re-initialization and for
lzma_filters_update(). To trigger it, an application had
to either re-initialize an existing encoder instance with
lzma_stream_encoder() or use lzma_filters_update(), and
then one of the 1-4 tiny allocations in lzma_filters_copy()
(called from stream_encoder_update()) must fail. An error
was correctly reported but the encoder state was corrupted.

This is related to the recent fix in
f8ee61e74eb40600445fdb601c374d582e1e9c8a which is good but
it wasn't enough to fix the main problem in stream_encoder.c.

2 years agoliblzma: Fix language in a comment.
Lasse Collin [Tue, 22 Nov 2022 14:37:15 +0000 (16:37 +0200)] 
liblzma: Fix language in a comment.

2 years agoliblzma: Fix infinite loop in LZMA encoder init with dict_size >= 2 GiB.
Lasse Collin [Tue, 22 Nov 2022 09:20:17 +0000 (11:20 +0200)] 
liblzma: Fix infinite loop in LZMA encoder init with dict_size >= 2 GiB.

The encoder doesn't support dictionary sizes larger than 1536 MiB.
This is validated, for example, when calculating the memory usage
via lzma_raw_encoder_memusage(). It is also enforced by the LZ
part of the encoder initialization. However, LZMA encoder with
LZMA_MODE_NORMAL did an unsafe calculation with dict_size before
such validation and that results in an infinite loop if dict_size
was 2 << 30 or greater.

2 years agoliblzma: Fix two Doxygen commands in the API headers.
Lasse Collin [Mon, 21 Nov 2022 11:02:33 +0000 (13:02 +0200)] 
liblzma: Fix two Doxygen commands in the API headers.

These were caught by clang -Wdocumentation.

2 years agoBump version and soname for 5.2.8. v5.2.8
Lasse Collin [Sun, 13 Nov 2022 17:58:47 +0000 (19:58 +0200)] 
Bump version and soname for 5.2.8.

2 years agoAdd NEWS for 5.2.8.
Lasse Collin [Sun, 13 Nov 2022 17:57:26 +0000 (19:57 +0200)] 
Add NEWS for 5.2.8.

2 years agoUpdate THANKS.
Lasse Collin [Fri, 11 Nov 2022 15:16:03 +0000 (17:16 +0200)] 
Update THANKS.

2 years agoliblzma: Fix building with Intel ICC (the classic compiler).
Lasse Collin [Fri, 11 Nov 2022 15:15:25 +0000 (17:15 +0200)] 
liblzma: Fix building with Intel ICC (the classic compiler).

It claims __GNUC__ >= 10 but doesn't support __symver__ attribute.

Thanks to Stephen Sachs.

2 years agoliblzma: Fix incorrect #ifdef for x86 SSE2 support.
Lasse Collin [Fri, 11 Nov 2022 12:35:58 +0000 (14:35 +0200)] 
liblzma: Fix incorrect #ifdef for x86 SSE2 support.

__SSE2__ is the correct macro for SSE2 support with GCC, Clang,
and ICC. __SSE2_MATH__ means doing floating point math with SSE2
instead of 387. Often the latter macro is defined if the first
one is but it was still a bug.

2 years agoScripts: Ignore warnings from xz.
Lasse Collin [Fri, 11 Nov 2022 10:23:58 +0000 (12:23 +0200)] 
Scripts: Ignore warnings from xz.

In practice this means making the scripts work when
the input files have an unsupported check type which
isn't a problem in practice unless support for
some check types has been disabled at build time.

2 years agoxz: Add comments about stdin and src_st.st_size.
Lasse Collin [Wed, 9 Nov 2022 12:10:52 +0000 (14:10 +0200)] 
xz: Add comments about stdin and src_st.st_size.

"xz -v < regular_file > out.xz" doesn't display the percentage
and estimated remaining time because it doesn't even try to
check the input file size when input is read from stdin.
This could be improved but for now there's just a comment
to remind about it.

2 years agoxz: Fix displaying of file sizes in progress indicator in passthru mode.
Lasse Collin [Wed, 9 Nov 2022 10:48:22 +0000 (12:48 +0200)] 
xz: Fix displaying of file sizes in progress indicator in passthru mode.

It worked for one input file since the counters are zero when
xz starts but they weren't reset when starting a new file in
passthru mode. For example, if files A, B, and C are one byte each,
then "xz -dcvf A B C" would show file sizes as 1, 2, and 3 bytes
instead of 1, 1, and 1 byte.

2 years agoxz: Add a comment why --to-stdout is not in --help.
Lasse Collin [Wed, 9 Nov 2022 09:27:20 +0000 (11:27 +0200)] 
xz: Add a comment why --to-stdout is not in --help.

It is on the man page still.

2 years agoDocs: Update faq.txt a little.
Lasse Collin [Tue, 8 Nov 2022 20:26:54 +0000 (22:26 +0200)] 
Docs: Update faq.txt a little.

2 years agoliblzma: Update API docs about decoder flags.
Lasse Collin [Tue, 8 Nov 2022 12:13:03 +0000 (14:13 +0200)] 
liblzma: Update API docs about decoder flags.

2 years agoliblzma: Fix a comment in auto_decoder.c.
Lasse Collin [Tue, 8 Nov 2022 12:00:58 +0000 (14:00 +0200)] 
liblzma: Fix a comment in auto_decoder.c.

2 years agoxz: Avoid a compiler warning in progress_speed() in message.c.
Jia Tan [Mon, 7 Nov 2022 14:24:14 +0000 (16:24 +0200)] 
xz: Avoid a compiler warning in progress_speed() in message.c.

This should be smaller too since it avoids the string constants.

2 years agoBuild: Clarify comment in configure.ac about SSE2.
Lasse Collin [Mon, 31 Oct 2022 14:26:05 +0000 (16:26 +0200)] 
Build: Clarify comment in configure.ac about SSE2.

2 years agoBuild: Remove obsolete commented-out lines from configure.ac.
Lasse Collin [Mon, 31 Oct 2022 14:16:37 +0000 (16:16 +0200)] 
Build: Remove obsolete commented-out lines from configure.ac.

2 years agoWindows: Fix mythread_once() macro with Vista threads.
Lasse Collin [Mon, 31 Oct 2022 11:31:58 +0000 (13:31 +0200)] 
Windows: Fix mythread_once() macro with Vista threads.

Don't call InitOnceComplete() if initialization was already done.

So far mythread_once() has been needed only when building
with --enable-small. windows/build.bash does this together
with --disable-threads so the Vista-specific mythread_once()
is never needed by those builds. VS project files or
CMake-builds don't support HAVE_SMALL builds at all.

2 years agoCMake: Sync tuklib_cpucores.cmake with tuklib_cpucores.m4.
Lasse Collin [Mon, 31 Oct 2022 09:49:47 +0000 (11:49 +0200)] 
CMake: Sync tuklib_cpucores.cmake with tuklib_cpucores.m4.

This was forgotten from commit 2611c4d90535652d3eb7ef4a026a6691276fab43.

2 years agoBuild: Use AC_CONFIG_HEADERS instead of the ancient AC_CONFIG_HEADER.
Lasse Collin [Tue, 25 Oct 2022 20:45:03 +0000 (23:45 +0300)] 
Build: Use AC_CONFIG_HEADERS instead of the ancient AC_CONFIG_HEADER.

We require Autoconf >= 2.69 and that has AC_CONFIG_HEADERS.

There is a warning about AC_PROG_CC_C99 being obsolete but
it cannot be removed because it is needed with Autoconf 2.69.

2 years agoBuild: Update m4/ax_pthread.m4 from Autoconf Archive.
Lasse Collin [Tue, 25 Oct 2022 20:31:44 +0000 (23:31 +0300)] 
Build: Update m4/ax_pthread.m4 from Autoconf Archive.

2 years agoxz: Fix --single-stream with an empty .xz Stream.
Lasse Collin [Tue, 25 Oct 2022 20:09:11 +0000 (23:09 +0300)] 
xz: Fix --single-stream with an empty .xz Stream.

Example:

    $ xz -dc --single-stream good-0-empty.xz
    xz: good-0-empty.xz: Internal error (bug)

The code, that is tries to catch some input file issues early,
didn't anticipate LZMA_STREAM_END which is possible in that
code only when --single-stream is used.

2 years agoxz: Fix decompressor behavior if input uses an unsupported check type.
Lasse Collin [Tue, 25 Oct 2022 16:07:17 +0000 (19:07 +0300)] 
xz: Fix decompressor behavior if input uses an unsupported check type.

Now files with unsupported check will make xz display
a warning, set the exit status to 2 (unless --no-warn is used),
and then decompress the file normally. This is how it was
supposed to work since the beginning but this was broken by
the commit 231c3c7098f1099a56abb8afece76fc9b8699f05, that is,
a little before 5.0.0 was released. The buggy behavior displayed
a message, set exit status 1 (error), and xz didn't attempt to
to decompress the file.

This doesn't matter today except for special builds that disable
CRC64 or SHA-256 at build time (but such builds should be used
in special situations only). The bug matters if new check type
is added in the future and an old xz version is used to decompress
such a file; however, it's likely that such files would use a new
filter too and an old xz wouldn't be able to decompress the file
anyway.

The first hunk in the commit is the actual fix. The second hunk
is a cleanup since LZMA_TELL_ANY_CHECK isn't used in xz.

There is a test file for unsupported check type but it wasn't
used by test_files.sh, perhaps due to different behavior between
xz and the simpler xzdec.