From 7e86a7632c98657be3967a3fe5304d696574aa23 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 12 Dec 2022 15:45:04 +0200 Subject: [PATCH 1/9] Update THANKS (sync all from master). --- THANKS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/THANKS b/THANKS index 6b7a0742..bbdc079e 100644 --- a/THANKS +++ b/THANKS @@ -42,8 +42,11 @@ 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 @@ -51,6 +54,8 @@ has been important. :-) In alphabetical order: - Christian Hesse - Vincenzo Innocente - Peter Ivanov + - Nicholas Jackson + - Sam James - Jouk Jansen - Jun I Jin - Kiyoshi Kanazawa @@ -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 @@ -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 From ef315163efdf82e327608ae9b8df1bfea42eb6b5 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 1 Dec 2022 20:04:17 +0200 Subject: [PATCH 2/9] 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. --- src/liblzma/common/common.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h index 7fb1732a..671d3bc4 100644 --- a/src/liblzma/common/common.h +++ b/src/liblzma/common/common.h @@ -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. @@ -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 From 7623b22d1d59c78033425a2448613837bcd203a2 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 8 Dec 2022 17:30:09 +0200 Subject: [PATCH 3/9] 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. --- src/liblzma/common/block_header_decoder.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/liblzma/common/block_header_decoder.c b/src/liblzma/common/block_header_decoder.c index 2e1135dd..060479b4 100644 --- a/src/liblzma/common/block_header_decoder.c +++ b/src/liblzma/common/block_header_decoder.c @@ -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) { From 4af80d4f5131bcdc827020ddc64172531f365bd7 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 8 Dec 2022 19:18:16 +0200 Subject: [PATCH 4/9] 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. --- src/xz/args.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/xz/args.c b/src/xz/args.c index 9238fb32..7c327a5e 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -31,7 +31,7 @@ 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; @@ -39,9 +39,18 @@ parse_memlimit(const char *name, const char *name_percentage, char *str, 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 @@ -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); @@ -112,6 +125,8 @@ parse_block_list(char *str) // Terminate the array. opt_block_list[count] = 0; + + free(str_start); return; } From 59a17888e96d748a119558e793ebb60d7f08a857 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 8 Dec 2022 19:24:22 +0200 Subject: [PATCH 5/9] xz: Make args_info.files_name a const pointer. --- src/xz/args.c | 2 +- src/xz/args.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xz/args.c b/src/xz/args.c index 7c327a5e..b0d63d69 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -490,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; diff --git a/src/xz/args.h b/src/xz/args.h index 46a8e8ed..a1a5930a 100644 --- a/src/xz/args.h +++ b/src/xz/args.h @@ -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. From 90f8e0828b95bb91b07eb29a64c4cabb182e7c89 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 12 Dec 2022 19:09:20 +0200 Subject: [PATCH 6/9] Update AUTHORS. --- AUTHORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index d55d0518..4c5c9784 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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. From e207267c4b735a31dbf8495b32f76113a188bc98 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 13 Dec 2022 12:30:45 +0200 Subject: [PATCH 7/9] Tests: Fix a typo in tests/files/README. --- tests/files/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/files/README b/tests/files/README index 3e550dfe..e28d908e 100644 --- a/tests/files/README +++ b/tests/files/README @@ -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. From e4e5d5bbb1b4965d9874b558520c48c6eaefdfcd Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 13 Dec 2022 13:02:15 +0200 Subject: [PATCH 8/9] Add NEWS for 5.2.10. --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index ebb30308..d92fa88a 100644 --- a/NEWS +++ b/NEWS @@ -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: From f7c2cc55618b9af3318f0c908cf8db0df1e28e7c Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 13 Dec 2022 13:03:20 +0200 Subject: [PATCH 9/9] Bump version and soname for 5.2.10. --- src/liblzma/Makefile.am | 2 +- src/liblzma/api/lzma/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liblzma/Makefile.am b/src/liblzma/Makefile.am index de56a20c..0e2e349a 100644 --- a/src/liblzma/Makefile.am +++ b/src/liblzma/Makefile.am @@ -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 diff --git a/src/liblzma/api/lzma/version.h b/src/liblzma/api/lzma/version.h index 087bf134..7b775351 100644 --- a/src/liblzma/api/lzma/version.h +++ b/src/liblzma/api/lzma/version.h @@ -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