Skip to content

Commit

Permalink
Merge commit 'd8a898eb9974683bc725c49ec76722f9a8758f48'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Dec 29, 2022
2 parents 5d6bfd1 + d8a898e commit 1dd9361
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 85 deletions.
6 changes: 3 additions & 3 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Authors of XZ Utils
<[email protected]> and Jia Tan <[email protected]>.

Major parts of liblzma are based on code written by Igor Pavlov,
specifically the LZMA SDK <http://7-zip.org/sdk.html>. Without
specifically the LZMA SDK <https://7-zip.org/sdk.html>. Without
this code, XZ Utils wouldn't exist.

The SHA-256 implementation in liblzma is based on the code found from
7-Zip <http://7-zip.org/>, which has a modified version of the SHA-256
code found from Crypto++ <http://www.cryptopp.com/>. The SHA-256 code
7-Zip <https://7-zip.org/>, which has a modified version of the SHA-256
code found from Crypto++ <https://www.cryptopp.com/>. The SHA-256 code
in Crypto++ was written by Kevin Springle and Wei Dai.

Some scripts have been adapted from gzip. The original versions
Expand Down
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set(CMAKE_MACOSX_BUNDLE OFF)
add_compile_definitions(
# Package info:
PACKAGE_NAME="XZ Utils"
PACKAGE_BUGREPORT="lasse.collin@tukaani.org"
PACKAGE_BUGREPORT="xz@tukaani.org"
PACKAGE_URL="https://tukaani.org/xz/"

# Features:
Expand Down Expand Up @@ -424,17 +424,24 @@ if(WIN32)
# Disable __declspec(dllimport) when linking against static liblzma.
target_compile_definitions(liblzma INTERFACE LZMA_API_STATIC)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif(BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
# GNU/Linux-specific symbol versioning for shared liblzma.
# Note that adding link options doesn't affect static builds.
target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX)
# Note that adding link options doesn't affect static builds
# but HAVE_SYMBOL_VERSIONS_LINUX must not be used with static builds
# because it would put symbol versions into the static library which
# can cause problems. It's clearer if all symver related things are
# omitted when not building a shared library.
#
# NOTE: Set it explicitly to 1 to make it clear that versioning is
# done unconditionally in the C files.
target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX=1)
target_link_options(liblzma PRIVATE
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
)
set_target_properties(liblzma PROPERTIES
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
elseif(BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# Symbol versioning for shared liblzma for non-GNU/Linux.
# FIXME? What about Solaris?
target_link_options(liblzma PRIVATE
Expand Down
34 changes: 34 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
XZ Utils Release Notes
======================

5.2.9 (2022-11-30)

* liblzma:

- Fixed an infinite loop in LZMA encoder initialization
if dict_size >= 2 GiB. (The encoder only supports up
to 1536 MiB.)

- Fixed two cases of invalid free() that can happen if
a tiny allocation fails in encoder re-initialization
or in lzma_filters_update(). These bugs had some
similarities with the bug fixed in 5.2.7.

- Fixed lzma_block_encoder() not allowing the use of
LZMA_SYNC_FLUSH with lzma_code() even though it was
documented to be supported. The sync-flush code in
the Block encoder was already used internally via
lzma_stream_encoder(), so this was just a missing flag
in the lzma_block_encoder() API function.

- GNU/Linux only: Don't put symbol versions into static
liblzma as it breaks things in some cases (and even if
it didn't break anything, symbol versions in static
libraries are useless anyway). The downside of the fix
is that if the configure options --with-pic or --without-pic
are used then it's not possible to build both shared and
static liblzma at the same time on GNU/Linux anymore;
with those options --disable-static or --disable-shared
must be used too.

* New email address for bug reports is <[email protected]> which
forwards messages to Lasse Collin and Jia Tan.


5.2.8 (2022-11-13)

* xz:
Expand Down
11 changes: 5 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ XZ Utils
----------------------

If you have questions, bug reports, patches etc. related to XZ Utils,
contact Lasse Collin <[email protected]> (in Finnish or English).
I'm sometimes slow at replying. If you haven't got a reply within two
weeks, assume that your email has got lost and resend it or use IRC.
the project maintainers Lasse Collin and Jia Tan can be reached via
<[email protected]>.

You can find me also from #tukaani on Freenode; my nick is Larhzu.
The channel tends to be pretty quiet, so just ask your question and
someone may wake up.
You might find Lasse also from #tukaani on Libera Chat (IRC).
The nick is Larhzu. The channel tends to be pretty quiet,
so just ask your question and someone might wake up.

145 changes: 96 additions & 49 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
AC_PREREQ([2.69])

AC_INIT([XZ Utils], m4_esyscmd([/bin/sh build-aux/version.sh]),
[lasse.collin@tukaani.org], [xz], [https://tukaani.org/xz/])
[xz@tukaani.org], [xz], [https://tukaani.org/xz/])
AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
Expand Down Expand Up @@ -469,54 +469,6 @@ AC_ARG_ENABLE([doc], [AS_HELP_STRING([--disable-doc],
AM_CONDITIONAL([COND_DOC], [test x$enable_doc != xno])


#####################
# Symbol versioning #
#####################

AC_MSG_CHECKING([if library symbol versioning should be used])
AC_ARG_ENABLE([symbol-versions], [AS_HELP_STRING([--enable-symbol-versions],
[Use symbol versioning for liblzma. Enabled by default on
GNU/Linux, other GNU-based systems, and FreeBSD.])],
[], [enable_symbol_versions=auto])
if test "x$enable_symbol_versions" = xauto; then
case $host_os in
# NOTE: Even if one omits -gnu on GNU/Linux (e.g.
# i486-slackware-linux), configure will (via config.sub)
# append -gnu (e.g. i486-slackware-linux-gnu), and this
# test will work correctly.
gnu* | *-gnu* | freebsd*)
enable_symbol_versions=yes
;;
*)
enable_symbol_versions=no
;;
esac
fi
AC_MSG_RESULT([$enable_symbol_versions])

# There are two variants for symbol versioning.
# See src/liblzma/validate_map.sh for details.
if test "x$enable_symbol_versions" = xyes; then
case $host_os in
linux*)
enable_symbol_versions=linux
AC_DEFINE([HAVE_SYMBOL_VERSIONS_LINUX], [1],
[Define to 1 to if GNU/Linux-specific details
are wanted for symbol versioning. This must
be used together with liblzma_linux.map.])
;;
*)
enable_symbol_versions=generic
;;
esac
fi

AM_CONDITIONAL([COND_SYMVERS_LINUX],
[test "x$enable_symbol_versions" = xlinux])
AM_CONDITIONAL([COND_SYMVERS_GENERIC],
[test "x$enable_symbol_versions" = xgeneric])


##############
# Sandboxing #
##############
Expand Down Expand Up @@ -663,6 +615,101 @@ LT_LANG([Windows Resource])
# libs as shared.
AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])

#####################
# Symbol versioning #
#####################

# NOTE: This checks if we are building shared or static library
# and if --with-pic or --without-pic was used. Thus this check
# must be after Libtool initialization.
AC_MSG_CHECKING([if library symbol versioning should be used])
AC_ARG_ENABLE([symbol-versions], [AS_HELP_STRING([--enable-symbol-versions],
[Use symbol versioning for liblzma. Enabled by default on
GNU/Linux, other GNU-based systems, and FreeBSD.])],
[], [enable_symbol_versions=auto])
if test "x$enable_symbol_versions" = xauto; then
case $host_os in
# NOTE: Even if one omits -gnu on GNU/Linux (e.g.
# i486-slackware-linux), configure will (via config.sub)
# append -gnu (e.g. i486-slackware-linux-gnu), and this
# test will work correctly.
gnu* | *-gnu* | freebsd*)
enable_symbol_versions=yes
;;
*)
enable_symbol_versions=no
;;
esac
fi

# There are two variants for symbol versioning.
# See src/liblzma/validate_map.sh for details.
#
# On GNU/Linux, extra symbols are added in the C code. These extra symbols
# must not be put into a static library as they can cause problems (and
# even if they didn't cause problems, they would be useless). On other
# systems symbol versioning may be used too but there is no problem as only
# a linker script is specified in src/liblzma/Makefile.am and that isn't
# used when creating a static library.
#
# Libtool always uses -DPIC when building shared libraries by default and
# doesn't use it for static libs by default. This can be overriden with
# --with-pic and --without-pic though. As long as neither --with-pic nor
# --without-pic is used then we can use #ifdef PIC to detect if the file is
# being built for a shared library.
if test "x$enable_symbol_versions" = xno ; then
enable_symbol_versions=no
AC_MSG_RESULT([no])
elif test "x$enable_shared" = xno ; then
enable_symbol_versions=no
AC_MSG_RESULT([no (not building a shared library)])
else
case $host_os in
linux*)
case "$pic_mode-$enable_static" in
default-*)
# Use symvers if PIC is defined.
have_symbol_versions_linux=2
;;
*-no)
# Not building static library.
# Use symvers unconditionally.
have_symbol_versions_linux=1
;;
*)
AC_MSG_RESULT([])
AC_MSG_ERROR([
On GNU/Linux, building both shared and static library at the same time
is not supported if --with-pic or --without-pic is used.
Use either --disable-shared or --disable-static to build one type
of library at a time. If both types are needed, build one at a time,
possibly picking only src/liblzma/.libs/liblzma.a from the static build.])
;;
esac
enable_symbol_versions=linux
AC_DEFINE_UNQUOTED([HAVE_SYMBOL_VERSIONS_LINUX],
[$have_symbol_versions_linux],
[Define to 1 to if GNU/Linux-specific details
are unconditionally wanted for symbol
versioning. Define to 2 to if these are wanted
only if also PIC is defined (allows building
both shared and static liblzma at the same
time with Libtool if neither --with-pic nor
--without-pic is used). This define must be
used together with liblzma_linux.map.])
;;
*)
enable_symbol_versions=generic
;;
esac
AC_MSG_RESULT([yes ($enable_symbol_versions)])
fi

AM_CONDITIONAL([COND_SYMVERS_LINUX],
[test "x$enable_symbol_versions" = xlinux])
AM_CONDITIONAL([COND_SYMVERS_GENERIC],
[test "x$enable_symbol_versions" = xgeneric])


###############################################################################
# Checks for libraries.
Expand Down
2 changes: 1 addition & 1 deletion dos/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#define NDEBUG 1

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
#define PACKAGE_BUGREPORT "xz@tukaani.org"

/* Define to the full name of this package. */
#define PACKAGE_NAME "XZ Utils"
Expand Down
2 changes: 1 addition & 1 deletion src/liblzma/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ liblzma_la_CPPFLAGS = \
-I$(top_srcdir)/src/liblzma/simple \
-I$(top_srcdir)/src/common \
-DTUKLIB_SYMBOL_PREFIX=lzma_
liblzma_la_LDFLAGS = -no-undefined -version-info 7:8:2
liblzma_la_LDFLAGS = -no-undefined -version-info 7:9:2

EXTRA_DIST += liblzma_generic.map liblzma_linux.map validate_map.sh
if COND_SYMVERS_GENERIC
Expand Down
3 changes: 2 additions & 1 deletion src/liblzma/api/lzma/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
*/
extern LZMA_API(lzma_ret) lzma_filters_copy(
const lzma_filter *src, lzma_filter *dest,
const lzma_allocator *allocator) lzma_nothrow;
const lzma_allocator *allocator)
lzma_nothrow lzma_attr_warn_unused_result;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/liblzma/api/lzma/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
* If the hardware supports more than one thread per CPU core, the number
* of hardware threads is returned if that information is available.
*
* \brief On success, the number of available CPU threads or cores is
* \return On success, the number of available CPU threads or cores is
* returned. If this information isn't available or an error
* occurs, zero is returned.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/liblzma/api/lzma/index_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern LZMA_API(void) lzma_index_hash_end(
/**
* \brief Add a new Record to an Index hash
*
* \param index Pointer to a lzma_index_hash structure
* \param index_hash Pointer to a lzma_index_hash structure
* \param unpadded_size Unpadded Size of a Block
* \param uncompressed_size Uncompressed Size of a Block
*
Expand Down
2 changes: 1 addition & 1 deletion src/liblzma/api/lzma/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
#define LZMA_VERSION_MAJOR 5
#define LZMA_VERSION_MINOR 2
#define LZMA_VERSION_PATCH 8
#define LZMA_VERSION_PATCH 9
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE

#ifndef LZMA_VERSION_COMMIT
Expand Down
1 change: 1 addition & 0 deletions src/liblzma/common/block_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ lzma_block_encoder(lzma_stream *strm, lzma_block *block)
lzma_next_strm_init(lzma_block_encoder_init, strm, block);

strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;

return LZMA_OK;
Expand Down
12 changes: 12 additions & 0 deletions src/liblzma/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@

#include "lzma.h"

// The extra symbol versioning in the C files may only be used when
// building a shared library. If HAVE_SYMBOL_VERSIONS_LINUX is defined
// to 2 then symbol versioning is done only if also PIC is defined.
// By default Libtool defines PIC when building a shared library and
// doesn't define it when building a static library but it can be
// overriden with --with-pic and --without-pic. configure let's rely
// on PIC if neither --with-pic or --without-pic was used.
#if defined(HAVE_SYMBOL_VERSIONS_LINUX) \
&& (HAVE_SYMBOL_VERSIONS_LINUX == 2 && !defined(PIC))
# undef HAVE_SYMBOL_VERSIONS_LINUX
#endif

#ifdef HAVE_SYMBOL_VERSIONS_LINUX
// To keep link-time optimization (LTO, -flto) working with GCC,
// the __symver__ attribute must be used instead of __asm__(".symver ...").
Expand Down
4 changes: 2 additions & 2 deletions src/liblzma/common/filter_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const lzma_filter_encoder encoders[] = {
.id = LZMA_FILTER_LZMA1,
.init = &lzma_lzma_encoder_init,
.memusage = &lzma_lzma_encoder_memusage,
.block_size = NULL, // FIXME
.block_size = NULL, // Not needed for LZMA1
.props_size_get = NULL,
.props_size_fixed = 5,
.props_encode = &lzma_lzma_props_encode,
Expand All @@ -70,7 +70,7 @@ static const lzma_filter_encoder encoders[] = {
.id = LZMA_FILTER_LZMA2,
.init = &lzma_lzma2_encoder_init,
.memusage = &lzma_lzma2_encoder_memusage,
.block_size = &lzma_lzma2_block_size, // FIXME
.block_size = &lzma_lzma2_block_size,
.props_size_get = NULL,
.props_size_fixed = 1,
.props_encode = &lzma_lzma2_props_encode,
Expand Down
Loading

0 comments on commit 1dd9361

Please sign in to comment.