Skip to content

Commit

Permalink
Merge commit 'f7c2cc55618b9af3318f0c908cf8db0df1e28e7c'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Dec 29, 2022
2 parents 1dd9361 + f7c2cc5 commit b33467d
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 10 deletions.
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Authors of XZ Utils
Andrew Dudman helped adapting the scripts and their man pages for
XZ Utils.

Other authors:
- Jonathan Nieder
- Joachim Henke

The GNU Autotools-based build system contains files from many authors,
which I'm not trying to list here.

Expand Down
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
XZ Utils Release Notes
======================

5.2.10 (2022-12-13)

* xz: Don't modify argv[] when parsing the --memlimit* and
--block-list command line options. This fixes confusing
arguments in process listing (like "ps auxf").

* GNU/Linux only: Use __has_attribute(__symver__) to detect if
that attribute is supported. This fixes build on Mandriva where
Clang is patched to define __GNUC__ to 11 by default (instead
of 4 as used by Clang upstream).


5.2.9 (2022-11-30)

* liblzma:
Expand Down
8 changes: 8 additions & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ has been important. :-) In alphabetical order:
- Michael Fox
- Mike Frysinger
- Daniel Richard G.
- Tomasz Gajc
- Bjarni Ingi Gislason
- John Paul Adrian Glaubitz
- Bill Glessner
- Michał Górny
- Jason Gorski
- Juan Manuel Guerrero
- Diederik de Haas
- Joachim Henke
- Christian Hesse
- Vincenzo Innocente
- Peter Ivanov
- Nicholas Jackson
- Sam James
- Jouk Jansen
- Jun I Jin
- Kiyoshi Kanazawa
Expand All @@ -63,6 +68,7 @@ has been important. :-) In alphabetical order:
- Stephan Kulow
- Peter Lawler
- James M Leddy
- Vincent Lefevre
- Hin-Tak Leung
- Andraž 'ruskie' Levstik
- Cary Lewis
Expand All @@ -79,6 +85,8 @@ has been important. :-) In alphabetical order:
- Ivan A. Melnikov
- Jim Meyering
- Arkadiusz Miskiewicz
- Nathan Moinvaziri
- Étienne Mollier
- Conley Moorhous
- Rafał Mużyło
- Adrien Nader
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:9:2
liblzma_la_LDFLAGS = -no-undefined -version-info 7:10:2

EXTRA_DIST += liblzma_generic.map liblzma_linux.map validate_map.sh
if COND_SYMVERS_GENERIC
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 9
#define LZMA_VERSION_PATCH 10
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE

#ifndef LZMA_VERSION_COMMIT
Expand Down
4 changes: 4 additions & 0 deletions src/liblzma/common/block_header_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ lzma_block_header_decode(lzma_block *block,
// are invalid or over 63 bits, or if the header is too small
// to contain the claimed information.

// Catch unexpected NULL pointers.
if (block == NULL || block->filters == NULL || in == NULL)
return LZMA_PROG_ERROR;

// Initialize the filter options array. This way the caller can
// safely free() the options even if an error occurs in this function.
for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {
Expand Down
15 changes: 14 additions & 1 deletion src/liblzma/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@

#include "lzma.h"

// This is for detecting modern GCC and Clang attributes
// like __symver__ in GCC >= 10.
#ifdef __has_attribute
# define lzma_has_attribute(attr) __has_attribute(attr)
#else
# define lzma_has_attribute(attr) 0
#endif

// 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.
Expand Down Expand Up @@ -63,7 +71,12 @@
// since 2000). When using @@ instead of @@@, the internal name must not be
// the same as the external name to avoid problems in some situations. This
// is why "#define foo_52 foo" is needed for the default symbol versions.
# if TUKLIB_GNUC_REQ(10, 0) && !defined(__INTEL_COMPILER)
//
// __has_attribute is supported before GCC 10 and it is supported in Clang 14
// too (which doesn't support __symver__) so use it to detect if __symver__
// is available. This should be far more reliable than looking at compiler
// version macros as nowadays especially __GNUC__ is defined by many compilers.
# if lzma_has_attribute(__symver__)
# define LZMA_SYMVER_API(extnamever, type, intname) \
extern __attribute__((__symver__(extnamever))) \
LZMA_API(type) intname
Expand Down
25 changes: 20 additions & 5 deletions src/xz/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,26 @@ const char stdin_filename[] = "(stdin)";

/// Parse and set the memory usage limit for compression and/or decompression.
static void
parse_memlimit(const char *name, const char *name_percentage, char *str,
parse_memlimit(const char *name, const char *name_percentage, const char *str,
bool set_compress, bool set_decompress)
{
bool is_percentage = false;
uint64_t value;

const size_t len = strlen(str);
if (len > 0 && str[len - 1] == '%') {
str[len - 1] = '\0';
// Make a copy so that we can get rid of %.
//
// In the past str wasn't const and we modified it directly
// but that modified argv[] and thus affected what was visible
// in "ps auxf" or similar tools which was confusing. For
// example, --memlimit=50% would show up as --memlimit=50
// since the percent sign was overwritten here.
char *s = xstrdup(str);
s[len - 1] = '\0';
is_percentage = true;
value = str_to_uint64(name_percentage, str, 1, 100);
value = str_to_uint64(name_percentage, s, 1, 100);
free(s);
} else {
// On 32-bit systems, SIZE_MAX would make more sense than
// UINT64_MAX. But use UINT64_MAX still so that scripts
Expand All @@ -56,8 +65,12 @@ parse_memlimit(const char *name, const char *name_percentage, char *str,


static void
parse_block_list(char *str)
parse_block_list(const char *str_const)
{
// We need a modifiable string in the for-loop.
char *str_start = xstrdup(str_const);
char *str = str_start;

// It must be non-empty and not begin with a comma.
if (str[0] == '\0' || str[0] == ',')
message_fatal(_("%s: Invalid argument to --block-list"), str);
Expand Down Expand Up @@ -112,6 +125,8 @@ parse_block_list(char *str)

// Terminate the array.
opt_block_list[count] = 0;

free(str_start);
return;
}

Expand Down Expand Up @@ -475,7 +490,7 @@ parse_real(args_info *args, int argc, char **argv)
"or `--files0'."));

if (optarg == NULL) {
args->files_name = (char *)stdin_filename;
args->files_name = stdin_filename;
args->files_file = stdin;
} else {
args->files_name = optarg;
Expand Down
2 changes: 1 addition & 1 deletion src/xz/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct {

/// Name of the file from which to read filenames. This is NULL
/// if --files or --files0 was not used.
char *files_name;
const char *files_name;

/// File opened for reading from which filenames are read. This is
/// non-NULL only if files_name is non-NULL.
Expand Down
2 changes: 1 addition & 1 deletion tests/files/README
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
uncompressed file is compress_prepared_bcj_x86 found from the tests
directory.

good-1-sparc-lzma2.xz uses the SPARC filter and LZMA. The
good-1-sparc-lzma2.xz uses the SPARC filter and LZMA2. The
uncompressed file is compress_prepared_bcj_sparc found from the tests
directory.

Expand Down

0 comments on commit b33467d

Please sign in to comment.