]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
21 months agoliblzma: Added crc32_clmul to crc32_fast.c.
Hans Jansen [Thu, 12 Oct 2023 17:37:01 +0000 (19:37 +0200)] 
liblzma: Added crc32_clmul to crc32_fast.c.

21 months agoliblzma: Moved CLMUL CRC logic to crc_common.h.
Hans Jansen [Thu, 12 Oct 2023 17:23:40 +0000 (19:23 +0200)] 
liblzma: Moved CLMUL CRC logic to crc_common.h.

crc64_fast.c was updated to use the code from crc_common.h instead.

21 months agoliblzma: Rename crc_macros.h to crc_common.h.
Hans Jansen [Thu, 12 Oct 2023 17:07:50 +0000 (19:07 +0200)] 
liblzma: Rename crc_macros.h to crc_common.h.

21 months agoCI: Bump and ref actions by commit SHA in windows-ci.yml
Gabriela Gutierrez [Tue, 26 Sep 2023 15:55:13 +0000 (15:55 +0000)] 
CI: Bump and ref actions by commit SHA in windows-ci.yml

Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch.

It's important to make sure the SHA's are from the original repositories and not forks.

For reference:

https://github.com/msys2/setup-msys2/releases/tag/v2.20.1
https://github.com/msys2/setup-msys2/commit/27b3aa77f672cb6b3054121cfd80c3d22ceebb1d

https://github.com/actions/checkout/releases/tag/v4.1.0
https://github.com/actions/checkout/commit/8ade135a41bc03ea155e62e844d188df1ea18608

https://github.com/actions/upload-artifact/releases/tag/v3.1.3
https://github.com/actions/upload-artifact/commit/a8a3f3ad30e3422c9c7b888a15615d19a852ae32

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
21 months agoCI: Bump and ref actions by commit SHA in ci.yml
Gabriela Gutierrez [Tue, 26 Sep 2023 14:35:08 +0000 (14:35 +0000)] 
CI: Bump and ref actions by commit SHA in ci.yml

Referencing actions by commit SHA in GitHub workflows guarantees you are using an immutable version. Actions referenced by tags and branches are more vulnerable to attacks, such as the tag being moved to a malicious commit or a malicious commit being pushed to the branch.

It's important to make sure the SHA's are from the original repositories and not forks.

For reference:

https://github.com/actions/checkout/releases/tag/v4.1.0
https://github.com/actions/checkout/commit/8ade135a41bc03ea155e62e844d188df1ea18608

https://github.com/actions/upload-artifact/releases/tag/v3.1.3
https://github.com/actions/upload-artifact/commit/a8a3f3ad30e3422c9c7b888a15615d19a852ae32

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
21 months agoBuild: Update visibility.m4 from Gnulib.
Jia Tan [Thu, 12 Oct 2023 12:12:18 +0000 (20:12 +0800)] 
Build: Update visibility.m4 from Gnulib.

Updating from version 6 -> 8 from upstream. Declarations for variables
and function bodies were added to avoid unnecessary failures with
-Werror.

22 months agoUpdate THANKS.
Lasse Collin [Fri, 6 Oct 2023 16:36:35 +0000 (19:36 +0300)] 
Update THANKS.

22 months agoCMake/Windows: Fix when the windres workaround is applied.
Lasse Collin [Fri, 6 Oct 2023 15:55:57 +0000 (18:55 +0300)] 
CMake/Windows: Fix when the windres workaround is applied.

CMake doesn't set WIN32 on CYGWIN but the workaround is
probably needed on Cygwin too. Same for MSYS and MSYS2.

The workaround must not be used with Clang that is acting in
MSVC mode. This fixes it by checking for the known environments
that need the workaround instead of using "NOT MSVC".

Thanks to Martin Storsjö.
https://github.com/tukaani-project/xz/commit/0570308ddd9c0e39e85597ebc0e31d4fc81d436f#commitcomment-129098431

22 months agoCI: Disable CLANG64 MSYS2 environment until bug is resolved.
Jia Tan [Fri, 29 Sep 2023 14:11:54 +0000 (22:11 +0800)] 
CI: Disable CLANG64 MSYS2 environment until bug is resolved.

lld 17.0.1 searches for libraries to link first in the toolchain
directories before the local directory when building. The is a problem
for us because liblzma.a is installed in MSYS2 CLANG64 by default and
xz.exe will thus use the installed library instead of the one being
built.

This causes tests to fail when they are expecting features to be
disabled. More importantly, it will compile xz.exe with an incorrect
liblzma and could cause unexpected behavior by being unable to update
liblzma code in static builds. The CLANG64 environment can be tested
again once this is fixed.

Link to bug: https://github.com/llvm/llvm-project/issues/67779.

22 months agoCMake: Rename xz and man page symlink custom targets.
Jia Tan [Fri, 29 Sep 2023 12:14:39 +0000 (20:14 +0800)] 
CMake: Rename xz and man page symlink custom targets.

The Ninja Generator for CMake cannot have a custom target and its
BYPRODUCTS have the same name. This has prevented Ninja builds on
Unix-like systems since the xz symlinks were introduced in
80a1a8bb838842a2be343bd88ad1462c21c5e2c9.

22 months agoCMake: Specify LINKER_LANGUAGE for libgnu target to fix Ninja Generator.
Jia Tan [Fri, 29 Sep 2023 11:58:44 +0000 (19:58 +0800)] 
CMake: Specify LINKER_LANGUAGE for libgnu target to fix Ninja Generator.

CMake is unable to guess the linker language for just a header file so
it must be explicitly set.

22 months agoCMake: Fix Windows build with Clang/LLVM 17.
Lasse Collin [Wed, 27 Sep 2023 16:54:35 +0000 (19:54 +0300)] 
CMake: Fix Windows build with Clang/LLVM 17.

llvm-windres 17.0.0 has more accurate emulation of GNU windres, so
the hack for GNU windres must now be used with llvm-windres too.

LLVM 16.0.6 has the old behavior and there likely won't be more
16.x releases. So we can simply check for >= 17.0.0.

See also:
https://github.com/llvm/llvm-project/commit/2bcc0fdc58a220cb9921b47ec8a32c85f2511a47

22 months agoliblzma: Update a comment.
Lasse Collin [Tue, 26 Sep 2023 18:47:13 +0000 (21:47 +0300)] 
liblzma: Update a comment.

The C standards don't allow an empty translation unit which can be
avoided by declaring something, without exporting any symbols.

When I committed f644473a211394447824ea00518d0a214ff3f7f2 I had
a feeling that some specific toolchain somewhere didn't like
empty object files (assembler or maybe "ar" complained) but
I cannot find anything to confirm this now. Quite likely I
remembered nonsense. I leave this here as a note to my future self. :-)

22 months agoliblzma: Avoid compiler warning without creating extra symbol.
Jia Tan [Tue, 26 Sep 2023 16:02:11 +0000 (00:02 +0800)] 
liblzma: Avoid compiler warning without creating extra symbol.

When the generic fast crc64 method is used, then we omit
lzma_crc64_table[][]. Similar to
d9166b52cf3458a4da3eb92224837ca8fc208d79, we can avoid compiler warnings
with -Wempty-translation-unit (Clang) or -pedantic (GCC) by creating a
never used typedef instead of an extra symbol.

22 months agoBuild: Update the comment about -Werror usage in checks.
Lasse Collin [Tue, 26 Sep 2023 14:24:15 +0000 (17:24 +0300)] 
Build: Update the comment about -Werror usage in checks.

22 months agoBuild: Fix __attribute__((ifunc(...))) detection with clang -Wall.
Lasse Collin [Tue, 26 Sep 2023 12:00:43 +0000 (15:00 +0300)] 
Build: Fix __attribute__((ifunc(...))) detection with clang -Wall.

Now if user-supplied CFLAGS contains -Wall -Wextra -Wpedantic
the two checks that need -Werror will still work.

At CMake side there is add_compile_options(-Wall -Wextra)
but it didn't affect the -Werror tests. So with both Autotools
and CMake only user-supplied CFLAGS could make the checks fail
when they shouldn't.

This is not a full fix as things like -Wunused-macros in
user-supplied CFLAGS will still cause problems with both
GCC and Clang.

22 months agoBuild: Fix underquoted AC_LANG_SOURCE.
Lasse Collin [Tue, 26 Sep 2023 10:51:31 +0000 (13:51 +0300)] 
Build: Fix underquoted AC_LANG_SOURCE.

It made no practical difference in this case.

22 months agoBuild: Silence two Autoconf warnings.
Lasse Collin [Tue, 26 Sep 2023 10:14:37 +0000 (13:14 +0300)] 
Build: Silence two Autoconf warnings.

There were two uses of AC_COMPILE_IFELSE that didn't use
AC_LANG_SOURCE and Autoconf warned about these. The omission
had been intentional but it turned out that this didn't do
what I thought it would.

Autoconf 2.71 manual gives an impression that AC_LANG_SOURCE
inserts all #defines that have been made with AC_DEFINE so
far (confdefs.h). The idea was that omitting AC_LANG_SOURCE
would mean that only the exact code included in the
AC_COMPILE_IFELSE call would be compiled.

With C programs this is not true: the #defines get added without
AC_LANG_SOURCE too. There seems to be no neat way to avoid this.
Thus, with the C language at least, adding AC_LANG_SOURCE makes
no other difference than silencing a warning from Autoconf. The
generated "configure" remains identical. (Docs of AC_LANG_CONFTEST
say that the #defines have been inserted since Autoconf 2.63b and
that AC_COMPILE_IFELSE uses AC_LANG_CONFTEST. So the behavior is
documented if one also reads the docs of macros that one isn't
calling directly.)

Any extra code, including #defines, can cause problems for
these two tests because these tests must use -Werror.
CC=clang CFLAGS=-Weverything is the most extreme example.
It enables -Wreserved-macro-identifier which warns about
#define __EXTENSIONS__ 1 because it begins with two underscores.
It's possible to write a test file that passes -Weverything but
it becomes impossible when Autoconf inserts confdefs.h.

So this commit adds AC_LANG_SOURCE to silence Autoconf warnings.
A different solution is needed for -Werror tests.

22 months agoCMake: Remove accidental extra newline.
Jia Tan [Mon, 25 Sep 2023 17:17:11 +0000 (01:17 +0800)] 
CMake: Remove accidental extra newline.

22 months agoBuild: Remove Gnulib dependency from tests.
Jia Tan [Mon, 25 Sep 2023 16:47:26 +0000 (00:47 +0800)] 
Build: Remove Gnulib dependency from tests.

The tests do not use any Gnulib replacements so they do not need to link
libgnu.a or have /lib in the include path.

22 months agoCMake: Remove /lib from tests include path.
Jia Tan [Mon, 25 Sep 2023 16:43:43 +0000 (00:43 +0800)] 
CMake: Remove /lib from tests include path.

The tests never included anything from /lib, so this was not needed.

22 months agoScripts: Change quoting style from `...' to '...'.
Jia Tan [Sun, 24 Sep 2023 14:10:41 +0000 (22:10 +0800)] 
Scripts: Change quoting style from `...' to '...'.

22 months agoxz: Change quoting style from `...' to '...'.
Jia Tan [Sun, 24 Sep 2023 14:10:18 +0000 (22:10 +0800)] 
xz: Change quoting style from `...' to '...'.

22 months agoliblzma: Change quoting style from `...' to '...'.
Jia Tan [Sun, 24 Sep 2023 14:09:47 +0000 (22:09 +0800)] 
liblzma: Change quoting style from `...' to '...'.

This was done for both internal and API headers.

22 months agoBuild: Change quoting style from `...' to '...'.
Jia Tan [Sun, 24 Sep 2023 14:09:16 +0000 (22:09 +0800)] 
Build: Change quoting style from `...' to '...'.

22 months agoDocs: Change quoting style from `...' to '...'.
Jia Tan [Sun, 24 Sep 2023 14:05:02 +0000 (22:05 +0800)] 
Docs: Change quoting style from `...' to '...'.

These days the ` and ' do not look symmetric. This quoting style has
been changed in various apps over the years including the GNU tools.

22 months agolib: Silence -Wsign-conversion in getopt.c.
Jia Tan [Sun, 24 Sep 2023 13:25:01 +0000 (21:25 +0800)] 
lib: Silence -Wsign-conversion in getopt.c.

22 months agoBuild: Update getopt.m4 from Gnulib.
Jia Tan [Sun, 24 Sep 2023 12:48:52 +0000 (20:48 +0800)] 
Build: Update getopt.m4 from Gnulib.

This file was modified from upstream since we do not need to replace
getopt() and can avoid complexity and feature tests.

22 months agoCMake: Add /lib to include path.
Jia Tan [Mon, 25 Sep 2023 16:09:53 +0000 (00:09 +0800)] 
CMake: Add /lib to include path.

22 months agoCMake: Update libgnu target with new header files.
Jia Tan [Sun, 24 Sep 2023 12:36:34 +0000 (20:36 +0800)] 
CMake: Update libgnu target with new header files.

22 months agolib: Update Makefile.am for new header files.
Jia Tan [Fri, 22 Sep 2023 16:47:52 +0000 (00:47 +0800)] 
lib: Update Makefile.am for new header files.

22 months agolib: Update getopt1.c from Gnulib.
Jia Tan [Sun, 24 Sep 2023 12:34:03 +0000 (20:34 +0800)] 
lib: Update getopt1.c from Gnulib.

The only difference was maintaining the conditional inclusion for
config.h.

22 months agolib: Update getopt.in.h from Gnulib with modifications.
Jia Tan [Fri, 22 Sep 2023 19:27:00 +0000 (03:27 +0800)] 
lib: Update getopt.in.h from Gnulib with modifications.

We can still avoid modifying the contents of this file during
configuration to simplify the build systems. Gnulib added replacements
for inclusions guards for Cygwin. Cygwin should not need getopt_long
replacement so this feature can be omitted.

<unistd.h> is conditionally included to avoid MSVC since it is not
available.

The definition for _GL_ARG_NONNULL was also copied into this file from
Gnulib since this stage is usually done during gnulib-tool.

22 months agolib: Update getopt_int.h from Gnulib.
Jia Tan [Fri, 22 Sep 2023 16:31:55 +0000 (00:31 +0800)] 
lib: Update getopt_int.h from Gnulib.

22 months agolib: Update getopt.c from Gnulib with modifications.
Jia Tan [Fri, 22 Sep 2023 16:27:23 +0000 (00:27 +0800)] 
lib: Update getopt.c from Gnulib with modifications.

The code maintains the prior modifications of conditionally including
config.h and disabling NLS support.

_GL_UNUSED is repalced with the simple cast to void trick. _GL_UNUSED
is only used for these two parameters so its simpler than having to
define it.

22 months agolib: Add getopt-cdefs.h for getopt_long update.
Jia Tan [Fri, 22 Sep 2023 16:18:56 +0000 (00:18 +0800)] 
lib: Add getopt-cdefs.h for getopt_long update.

This was modified slightly from Gnulib. In Gnulib, it expects the
@HAVE_SYS_CDEFS_H@ to be replaced. Instead, we can set HAVE_SYS_CDEFS_H
on systems that have it and avoid copying another file into the build
directory. Since we are not using gnulib-tool, copying extra files
requires extra build system updates (and special handling with CMake) so
we should avoid when possible.

22 months agolib: Copy new header files from Gnulib without modification.
Jia Tan [Fri, 22 Sep 2023 16:15:25 +0000 (00:15 +0800)] 
lib: Copy new header files from Gnulib without modification.

The getopt related files have changed from Gnulib by splitting up
getopt.in.h into more modular header files. We could have kept
everything in just getopt.in.h, but this will help us continue to update
in the future.

22 months agoWindows: Update the version requirement comments from Win95 to W2k.
Lasse Collin [Fri, 22 Sep 2023 18:16:52 +0000 (21:16 +0300)] 
Windows: Update the version requirement comments from Win95 to W2k.

22 months agotuklib_physmem: Comment out support for Windows versions older than 2000.
Lasse Collin [Fri, 22 Sep 2023 18:12:54 +0000 (21:12 +0300)] 
tuklib_physmem: Comment out support for Windows versions older than 2000.

22 months agosysdefs.h: Update the comment about __USE_MINGW_ANSI_STDIO.
Lasse Collin [Sun, 24 Sep 2023 13:32:32 +0000 (16:32 +0300)] 
sysdefs.h: Update the comment about __USE_MINGW_ANSI_STDIO.

22 months agoxz: Windows: Don't (de)compress to special files like "con" or "nul".
Lasse Collin [Thu, 21 Sep 2023 23:33:29 +0000 (02:33 +0300)] 
xz: Windows: Don't (de)compress to special files like "con" or "nul".

Before this commit, the following writes "foo" to the
console and deletes the input file:

    echo foo | xz > con_xz
    xz --suffix=_xz --decompress con_xz

It cannot happen without --suffix because names like con.xz
are also special and so attempting to decompress con.xz
(or compress con to con.xz) will already fail when opening
the input file.

Similar thing is possible when compressing. The following
writes to "nul" and the input file "n" is deleted.

    echo foo | xz > n
    xz --suffix=ul n

Now xz checks if the destination is a special file before
continuing. DOS/DJGPP version had a check for this but
Windows (and OS/2) didn't.

22 months agoCMake: Wrap two overlong lines that are possible to wrap.
Lasse Collin [Thu, 21 Sep 2023 17:42:52 +0000 (20:42 +0300)] 
CMake: Wrap two overlong lines that are possible to wrap.

22 months agoCMake: Add a comment about threads on Cygwin.
Lasse Collin [Thu, 21 Sep 2023 17:36:31 +0000 (20:36 +0300)] 
CMake: Add a comment about threads on Cygwin.

22 months agoMSVC: Remove Visual Studio project files and update INSTALL-MSVC.txt.
Lasse Collin [Tue, 12 Sep 2023 20:53:25 +0000 (23:53 +0300)] 
MSVC: Remove Visual Studio project files and update INSTALL-MSVC.txt.

CMake is now the preferred build file generator when building
with MSVC.

22 months agoCMake: Require VS2015 or later for building xzdec.
Lasse Collin [Thu, 21 Sep 2023 16:17:40 +0000 (19:17 +0300)] 
CMake: Require VS2015 or later for building xzdec.

xzdec might build with VS2013 but it hasn't been tested.
It was never supported before and VS2013 is old anyway
so for simplicity only liblzma is supported with VS2013.

22 months agoCMake: Allow building xz with Visual Studio 2015 and later.
Lasse Collin [Tue, 12 Sep 2023 20:43:49 +0000 (23:43 +0300)] 
CMake: Allow building xz with Visual Studio 2015 and later.

Building the command line tools xz and xzdec with the combination
of CMake + Visual Studio 2015/2017/2019/2022 works now.

VS2013 update 2 should still be able to build liblzma.
VS2013 cannot build the xz command line tool because xz
needs snprintf() that roughly conforms to C99.
VS2013 is old and no extra code will be added to support it.

Thanks to Kelvin Lee and Jia Tan for testing.

22 months agoMSVC: #define inline and restrict only when needed.
Lasse Collin [Tue, 12 Sep 2023 20:34:31 +0000 (23:34 +0300)] 
MSVC: #define inline and restrict only when needed.

This also drops the check for _WIN32 as that shouldn't be needed.

22 months agoCMake: Add support for replacement getopt_long (lib/getopt*).
Lasse Collin [Tue, 12 Sep 2023 19:16:56 +0000 (22:16 +0300)] 
CMake: Add support for replacement getopt_long (lib/getopt*).

Thanks to Jia Tan for the initial work. I added the libgnu target
and made a few related minor edits.

22 months agoCMake: Bump maximum policy version to 3.27.
Lasse Collin [Tue, 12 Sep 2023 18:12:34 +0000 (21:12 +0300)] 
CMake: Bump maximum policy version to 3.27.

There are several new policies. CMP0149 may affect the Windows SDK
version that CMake will choose by default. The new behavior is more
predictable, always choosing the latest SDK version by default.

The other new policies shouldn't affect this package.

22 months agolib/getopt*.c: Include <config.h> only HAVE_CONFIG_H is defined.
Lasse Collin [Tue, 12 Sep 2023 17:55:10 +0000 (20:55 +0300)] 
lib/getopt*.c: Include <config.h> only HAVE_CONFIG_H is defined.

The CMake-based build doesn't use config.h.

Up-to-date getopt_long in Gnulib is LGPLv2 so at some
point it could be included in XZ Utils too but for now
this commit is enough to make CMake-based build possible.

22 months agoDoxygen: Add more C macro names to PREDEFINED.
Lasse Collin [Fri, 8 Sep 2023 16:08:57 +0000 (19:08 +0300)] 
Doxygen: Add more C macro names to PREDEFINED.

22 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.

22 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".

22 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.

22 months agoBuild: Omit -Wc99-c11-compat since it warns about _Noreturn.
Lasse Collin [Fri, 8 Sep 2023 15:41:25 +0000 (18:41 +0300)] 
Build: Omit -Wc99-c11-compat since it warns about _Noreturn.

22 months agotuklib: Update tuklib_attr_noreturn for C11/C17 and C23.
Lasse Collin [Fri, 8 Sep 2023 15:19:26 +0000 (18:19 +0300)] 
tuklib: Update tuklib_attr_noreturn for C11/C17 and C23.

This makes no difference for GCC or Clang as they support
GNU C's __attribute__((__noreturn__)) but this helps with MSVC:

  - VS 2019 version 16.7 and later support _Noreturn if the
    options /std:c11 or /std:c17 are used. This gets handled
    with the check for __STDC_VERSION__ >= 201112.

  - When MSVC isn't in C11/C17 mode, __declspec(noreturn) is used.

C23 will deprecate _Noreturn (and <stdnoreturn.h>)
for [[noreturn]]. This commit anticipates that but
the final __STDC_VERSION__ value isn't known yet.

22 months agoUpdate THANKS.
Lasse Collin [Mon, 11 Sep 2023 14:22:44 +0000 (17:22 +0300)] 
Update THANKS.

22 months agoMSVC: xz: Make file_io.c and file_io.h compatible with MSVC.
Lasse Collin [Tue, 5 Sep 2023 19:42:10 +0000 (22:42 +0300)] 
MSVC: xz: Make file_io.c and file_io.h compatible with MSVC.

Thanks to Kelvin Lee for the original patches
and testing the modifications I made.

22 months agoMSVC: xz: Use GetTickCount64() to implement mytime_now().
Lasse Collin [Tue, 5 Sep 2023 18:33:35 +0000 (21:33 +0300)] 
MSVC: xz: Use GetTickCount64() to implement mytime_now().

It's available since Windows Vista.

22 months agoMSVC: xz: Use _stricmp() instead of strcasecmp() in suffix.c.
Kelvin Lee [Tue, 5 Sep 2023 12:05:09 +0000 (15:05 +0300)] 
MSVC: xz: Use _stricmp() instead of strcasecmp() in suffix.c.

22 months agoMSVC: xz: Use _isatty() from <io.h> to implement isatty().
Kelvin Lee [Tue, 5 Sep 2023 12:01:10 +0000 (15:01 +0300)] 
MSVC: xz: Use _isatty() from <io.h> to implement isatty().

22 months agoMSVC: xz: Use _fileno() instead of fileno().
Kelvin Lee [Tue, 5 Sep 2023 12:10:31 +0000 (15:10 +0300)] 
MSVC: xz: Use _fileno() instead of fileno().

22 months agoMSVC: xzdec: Use _fileno and _setmode.
Kelvin Lee [Tue, 5 Sep 2023 12:00:07 +0000 (15:00 +0300)] 
MSVC: xzdec: Use _fileno and _setmode.

22 months agoMSVC: Don't #include <unistd.h>.
Kelvin Lee [Tue, 5 Sep 2023 11:37:50 +0000 (14:37 +0300)] 
MSVC: Don't #include <unistd.h>.

22 months agoUpdate THANKS.
Lasse Collin [Tue, 19 Sep 2023 11:03:45 +0000 (14:03 +0300)] 
Update THANKS.

22 months agoCI: Enable CLMUL in address sanitization test.
Jia Tan [Thu, 14 Sep 2023 13:13:23 +0000 (21:13 +0800)] 
CI: Enable CLMUL in address sanitization test.

The crc64_clmul() function should be ignored by the address sanitizer
now so these builds should still pass.

22 months agoUpdate THANKS.
Lasse Collin [Thu, 14 Sep 2023 13:35:46 +0000 (16:35 +0300)] 
Update THANKS.

22 months agoliblzma: Mark crc64_clmul() with __attribute__((__no_sanitize_address__)).
Lasse Collin [Thu, 14 Sep 2023 13:34:07 +0000 (16:34 +0300)] 
liblzma: Mark crc64_clmul() with __attribute__((__no_sanitize_address__)).

Thanks to Agostino Sarubbo.
Fixes: https://github.com/tukaani-project/xz/issues/62
22 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.

22 months agoCMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.
Jia Tan [Tue, 12 Sep 2023 14:34:06 +0000 (22:34 +0800)] 
CMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.

If HAVE_CLOCK_GETTIME was defined, then HAVE_CLOCK_MONOTONIC was always
added as a compile definition even if the check for it failed.

23 months agoxz: Refactor thousand separator detection and disable it on MSVC.
Lasse Collin [Thu, 31 Aug 2023 16:50:05 +0000 (19:50 +0300)] 
xz: Refactor thousand separator detection and disable it on MSVC.

Now the two variations of the format strings are created with
a macro, and the whole detection code can be easily disabled
on platforms where thousand separator formatting is known to
not work (MSVC has no support, and on DJGPP 2.05 it can have
problems in some cases).

23 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.

23 months agoTests: Improve invalid unpadded size check in test_lzma_index_append().
Jia Tan [Mon, 28 Aug 2023 15:14:45 +0000 (23:14 +0800)] 
Tests: Improve invalid unpadded size check in test_lzma_index_append().

This check was extended to test the code added to fix a failing assert
in ae5c07b22a6b3766b84f409f1b6b5c100469068a.

23 months agoTests: Improve comments in test_index.c.
Jia Tan [Mon, 28 Aug 2023 13:54:41 +0000 (21:54 +0800)] 
Tests: Improve comments in test_index.c.

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

23 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.

23 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.

23 months agoTranslations: Update the Esperanto translation.
Jia Tan [Mon, 28 Aug 2023 14:18:29 +0000 (22:18 +0800)] 
Translations: Update the Esperanto translation.

23 months agoTranslations: Update the Esperanto translation.
Jia Tan [Sat, 26 Aug 2023 12:10:23 +0000 (20:10 +0800)] 
Translations: Update the Esperanto translation.

23 months agoDocs: Update INSTALL for --enable-threads method win95.
Jia Tan [Wed, 9 Aug 2023 12:55:36 +0000 (20:55 +0800)] 
Docs: Update INSTALL for --enable-threads method win95.

The Autotools build allows win95 threads and --enable-small together now
if the compiler supports __attribute__((__constructor__)).

23 months agoCMake: Conditionally allow win95 threads and --enable-small.
Jia Tan [Wed, 9 Aug 2023 12:54:15 +0000 (20:54 +0800)] 
CMake: Conditionally allow win95 threads and --enable-small.

23 months agoBuild: Conditionally allow win95 threads and --enable-small.
Jia Tan [Wed, 9 Aug 2023 12:35:16 +0000 (20:35 +0800)] 
Build: Conditionally allow win95 threads and --enable-small.

When the compiler supports __attribute__((__constructor__))
mythread_once() is never used, even with --enable-small. A configuration
with win95 threads and --enable-small will compile and be thread safe so
it can be allowed.

This isn't a very common configuration since MSVC does not support
__attribute__((__constructor__)), but MINGW32 and CLANG32 environments
for MSYS2 can use win95 threads and have
__attribute__((__constructor__)) support.

23 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.

2 years agocodespell: Add .codespellrc to set default options.
Jia Tan [Fri, 4 Aug 2023 14:17:11 +0000 (22:17 +0800)] 
codespell: Add .codespellrc to set default options.

The .codespellrc allows setting default options to avoid false positive
matches, set additional dictionaries, etc. For now, codespell can be
used locally before committing doc and comment changes.

It should help prevent silly errors and fix up commits in the future.

2 years agoTests: Style fixes to test_lzip_decoder.c.
Jia Tan [Thu, 3 Aug 2023 12:10:21 +0000 (20:10 +0800)] 
Tests: Style fixes to test_lzip_decoder.c.

2 years agoTranslations: Update the Chinese (simplified) translation.
Jia Tan [Thu, 3 Aug 2023 07:56:20 +0000 (15:56 +0800)] 
Translations: Update the Chinese (simplified) translation.

2 years agoxz: Omit an empty paragraph on the man page.
Lasse Collin [Wed, 2 Aug 2023 14:15:12 +0000 (17:15 +0300)] 
xz: Omit an empty paragraph on the man page.

2 years agoAdd NEWS for 5.4.4.
Jia Tan [Wed, 2 Aug 2023 12:30:07 +0000 (20:30 +0800)] 
Add NEWS for 5.4.4.

2 years 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.

2 years agoUpdate THANKS.
Lasse Collin [Tue, 1 Aug 2023 16:10:43 +0000 (19:10 +0300)] 
Update THANKS.

2 years agoUpdate THANKS.
Lasse Collin [Tue, 1 Aug 2023 15:22:24 +0000 (18:22 +0300)] 
Update THANKS.

2 years agomythread.h: Disable signal functions in builds targeting Wasm + WASI.
ChanTsune [Tue, 1 Aug 2023 15:17:17 +0000 (18:17 +0300)] 
mythread.h: Disable signal functions in builds targeting Wasm + WASI.

signal.h in WASI SDK doesn't currently provide sigprocmask()
or sigset_t. liblzma doesn't need them so this change makes
liblzma and xzdec build against WASI SDK. xz doesn't build yet
and the tests don't either as tuktest needs setjmp() which
isn't (yet?) implemented in WASI SDK.

Closes: https://github.com/tukaani-project/xz/pull/57
See also: https://github.com/tukaani-project/xz/pull/56

(The original commit was edited a little by Lasse Collin.)

2 years agoAdd newline to end of .gitignore.
Jia Tan [Tue, 1 Aug 2023 13:58:51 +0000 (21:58 +0800)] 
Add newline to end of .gitignore.

Newline was accidentally removed in commit
01cbb7f023ee7fda8ddde04bd17cf7d3c2418706.

2 years agoDocs: Fix typos found by codespell
Dimitri Papadopoulos Orfanos [Mon, 31 Jul 2023 12:02:21 +0000 (14:02 +0200)] 
Docs: Fix typos found by codespell

2 years agoUpdate .gitignore.
Jia Tan [Wed, 26 Jul 2023 12:26:23 +0000 (20:26 +0800)] 
Update .gitignore.

2 years agoCMake: Conditionally allow the creation of broken symlinks.
Jia Tan [Fri, 28 Jul 2023 14:03:08 +0000 (22:03 +0800)] 
CMake: Conditionally allow the creation of broken symlinks.

The CMake build will try to create broken symlinks on Unix and Unix-like
platforms. Cygwin and MSYS2 are Unix-like, but may not be able to create
broken symlinks. The value of the CYGWIN or MSYS environment variables
determine if broken symlinks are valid.

The default for MSYS2 does not allow for broken symlinks, so the CMake
build has been broken for MSYS2 since commit
80a1a8bb838842a2be343bd88ad1462c21c5e2c9.

2 years agoCI: Fix windows-ci dependency installation.
Jia Tan [Fri, 28 Jul 2023 13:56:48 +0000 (21:56 +0800)] 
CI: Fix windows-ci dependency installation.

All of the MSYS2 environments need make, and it does not come with the
toolchain package. The toolchain package will install the needed
compiler toolchains since without this package CMake cannot properly
generate the Makefiles.

2 years agoCI: Update ci_build.sh CMake to always make Unix Makefiles.
Jia Tan [Fri, 28 Jul 2023 13:54:22 +0000 (21:54 +0800)] 
CI: Update ci_build.sh CMake to always make Unix Makefiles.

The default for many of the MSYS2 environments is for CMake to create
Ninja build files. This would complicate the build script since we would
need a different command to run the tests. Its simpler to always use
Unix Makefiles so that "make test" is always a usable target for
testing.

2 years agoCI: Test CMake builds and test framework with MSYS2.
Jia Tan [Tue, 25 Jul 2023 12:17:23 +0000 (20:17 +0800)] 
CI: Test CMake builds and test framework with MSYS2.

2 years agoCI: Windows CI rename system matrix variable -> msys2_env.
Jia Tan [Tue, 25 Jul 2023 12:14:53 +0000 (20:14 +0800)] 
CI: Windows CI rename system matrix variable -> msys2_env.

Calling the MSYS2 environment "system" was a bit vague and should be
more specific.