aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-07-24xzgrep man page: Document exit statuses.Lasse Collin1-1/+14
2022-07-24xzgrep: Improve error handling, especially signals.Lasse Collin1-19/+53
xzgrep wouldn't exit on SIGPIPE or SIGQUIT when it clearly should have. It's quite possible that it's not perfect still but at least it's much better. If multiple exit statuses compete, now it tries to pick the largest of value. Some comments were added. The exit status handling of signals is still broken if the shell uses values larger than 255 in $? to indicate that a process died due to a signal ***and*** their "exit" command doesn't take this into account. This seems to work well with the ksh and yash versions I tried. However, there is a report in gzip/zgrep that OpenSolaris 5.11 (not 5.10) has a problem with "exit" truncating the argument to 8 bits: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22900#25 Such a bug would break xzgrep but I didn't add a workaround at least for now. 5.11 is old and I don't know if the problem exists in modern descendants, or if the problem exists in other ksh implementations in use.
2022-07-24xzgrep: Make the fix for ZDI-CAN-16587 more robust.Lasse Collin1-1/+4
I don't know if this can make a difference in the real world but it looked kind of suspicious (what happens with sed implementations that cannot process very long lines?). At least this commit shouldn't make it worse.
2022-07-24xzgrep: Use grep -H --label when available (GNU, *BSDs).Lasse Collin1-0/+21
It avoids the use of sed for prefixing filenames to output lines. Using sed for that is slower and prone to security bugs so now the sed method is only used as a fallback. This also fixes an actual bug: When grepping a binary file, GNU grep nowadays prints its diagnostics to stderr instead of stdout and thus the sed-method for prefixing the filename doesn't work. So with this commit grepping binary files gives reasonable output with GNU grep now. This was inspired by zgrep but the implementation is different.
2022-07-24xzgrep: Use -e to specify the pattern to grep.Lasse Collin1-8/+4
Now we don't need the separate test for adding the -q option as it can be added directly in the two places where it's needed.
2022-07-24Scripts: Use printf instead of echo in a few places.Lasse Collin4-11/+11
It's a good habbit as echo has some portability corner cases when the string contents can be anything.
2022-07-24xzgrep: Add more LC_ALL=C to avoid bugs with multibyte characters.Lasse Collin1-6/+8
Also replace one use of expr with printf. The rationale for LC_ALL=C was already mentioned in 69d1b3fc29677af8ade8dc15dba83f0589cb63d6 that fixed a security issue. However, unrelated uses weren't changed in that commit yet. POSIX says that with sed and such tools one should use LC_ALL=C to ensure predictable behavior when strings contain byte sequences that aren't valid multibyte characters in the current locale. See under "Application usage" in here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html With GNU sed invalid multibyte strings would work without this; it's documented in its Texinfo manual. Some other implementations aren't so forgiving.
2022-07-24xzgrep: Fix parsing of certain options.Lasse Collin1-2/+17
Fix handling of "xzgrep -25 foo" (in GNU grep "grep -25 foo" is an alias for "grep -C25 foo"). xzgrep would treat "foo" as filename instead of as a pattern. This bug was fixed in zgrep in gzip in 2012. Add -E, -F, -G, and -P to the "no argument required" list. Add -X to "argument required" list. It is an intentionally-undocumented GNU grep option so this isn't an important option for xzgrep but it seems that other grep implementations (well, those that I checked) don't support -X so I hope this change is an improvement still. grep -d (grep --directories=ACTION) requires an argument. In contrast to zgrep, I kept -d in the "no argument required" list because it's not supported in xzgrep (or zgrep). This way "xzgrep -d" gives an error about option being unsupported instead of telling that it requires an argument. Both zgrep and xzgrep tell that it's unsupported if an argument is specified. Add comments.
2022-07-24Tests: Add the .lzma files to test_files.sh.Lasse Collin1-0/+20
2022-07-24Tests: Add .lzma test files.Lasse Collin9-13/+50
2022-07-24liblzma: Rename a variable and improve a comment.Lasse Collin1-4/+9
2022-07-24Update THANKS.Lasse Collin1-0/+1
2022-07-24liblzma: Add optional autodetection of LZMA end marker.Lasse Collin6-38/+94
Turns out that this is needed for .lzma files as the spec in LZMA SDK says that end marker may be present even if the size is stored in the header. Such files are rare but exist in the real world. The code in liblzma is so old that the spec didn't exist in LZMA SDK back then and I had understood that such files weren't possible (the lzma tool in LZMA SDK didn't create such files). This modifies the internal API so that LZMA decoder can be told if EOPM is allowed even when the uncompressed size is known. It's allowed with .lzma and not with other uses. Thanks to Karl Beldan for reporting the problem.
2022-07-24Tests: Add test file good-1-empty-bcj-lzma2.xz.Lasse Collin2-0/+5
This is from test_bcj_exact_size.c. It's good to have it as a standalone file.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).Lasse Collin1-8/+12
Malicious filenames can make xzgrep to write to arbitrary files or (with a GNU sed extension) lead to arbitrary code execution. xzgrep from XZ Utils versions up to and including 5.2.5 are affected. 5.3.1alpha and 5.3.2alpha are affected as well. This patch works for all of them. This bug was inherited from gzip's zgrep. gzip 1.12 includes a fix for zgrep. The issue with the old sed script is that with multiple newlines, the N-command will read the second line of input, then the s-commands will be skipped because it's not the end of the file yet, then a new sed cycle starts and the pattern space is printed and emptied. So only the last line or two get escaped. One way to fix this would be to read all lines into the pattern space first. However, the included fix is even simpler: All lines except the last line get a backslash appended at the end. To ensure that shell command substitution doesn't eat a possible trailing newline, a colon is appended to the filename before escaping. The colon is later used to separate the filename from the grep output so it is fine to add it here instead of a few lines later. The old code also wasn't POSIX compliant as it used \n in the replacement section of the s-command. Using \<newline> is the POSIX compatible method. LC_ALL=C was added to the two critical sed commands. POSIX sed manual recommends it when using sed to manipulate pathnames because in other locales invalid multibyte sequences might cause issues with some sed implementations. In case of GNU sed, these particular sed scripts wouldn't have such problems but some other scripts could have, see: info '(sed)Locale Considerations' This vulnerability was discovered by: cleemy desu wayo working with Trend Micro Zero Day Initiative Thanks to Jim Meyering and Paul Eggert discussing the different ways to fix this and for coordinating the patch release schedule with gzip.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12liblzma: Fix docs: lzma_block_decoder() cannot return LZMA_UNSUPPORTED_CHECK.Lasse Collin1-3/+0
If Check is unsupported, it will be silently ignored. It's the caller's job to handle it.
2022-07-12liblzma: Index hash: Change return value type of hash_append() to void.Lasse Collin1-6/+5
2022-07-12liblzma: Minor addition to lzma_vli_size() API doc.Lasse Collin1-0/+2
Thanks to Jia Tan.
2022-07-12liblzma: Check the return value of lzma_index_append() in threaded encoder.Lasse Collin1-2/+5
If lzma_index_append() failed (most likely memory allocation failure) it could have gone unnoticed and the resulting .xz file would have an incorrect Index. Decompressing such a file would produce the correct uncompressed data but then an error would occur when verifying the Index field.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12liblzma: Use non-executable stack on FreeBSD as on LinuxEd Maste2-4/+4
2022-07-12liblzma: Make Block decoder catch certain types of errors better.Lasse Collin1-25/+54
Now it limits the input and output buffer sizes that are passed to a raw decoder. This way there's no need to check if the sizes can grow too big or overflow when updating Compressed Size and Uncompressed Size counts. This also means that a corrupt file cannot cause the raw decoder to process useless extra input or output that would exceed the size info in Block Header (and thus cause LZMA_DATA_ERROR anyway). More importantly, now the size information is verified more carefully in case raw decoder returns LZMA_OK. This doesn't really matter with the current single-threaded .xz decoder as the errors would be detected slightly later anyway. But this helps avoiding corner cases in the upcoming threaded decompressor, and it might help other Block decoder uses outside liblzma too. The test files bad-1-lzma2-{9,10,11}.xz test these conditions. With the single-threaded .xz decoder the only difference is that LZMA_DATA_ERROR is detected in a difference place now.
2022-07-12Tests: Add bad-1-lzma2-11.xz.Lasse Collin2-0/+5
2022-07-12Translations: Fix po4a failure with the French man page translations.Lasse Collin1-2/+4
Thanks to Mario Blättermann for the patch.
2022-07-12Translations: Add French translation of man pages.Lasse Collin2-1/+3542
This matches xz-utils 5.2.5-2 in Debian. The translation was done by "bubu", proofread by the debian-l10n-french mailing list contributors, and submitted to me on the xz-devel mailing list by Jean-Pierre Giraud. Thanks to everyone!
2022-07-12liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.jiat752-0/+6
Previously lzma_lzma_props_encode() and lzma_lzma2_props_encode() assumed that the options pointers must be non-NULL because the with these filters the API says it must never be NULL. It is good to do these checks anyway.
2022-07-12CMake: Keep compatible with Windows 95 for 32-bit build.huangqinjin1-1/+11
2022-07-12xzgrep: Update man page timestamp.Lasse Collin1-1/+1
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12xzgrep: use `grep -E/-F` instead of `egrep` and `fgrep`Ville Skyttä2-6/+6
`egrep` and `fgrep` have been deprecated in GNU grep since 2007, and in current post 3.7 Git they have been made to emit obsolescence warnings: https://git.savannah.gnu.org/cgit/grep.git/commit/?id=a9515624709865d480e3142fd959bccd1c9372d1
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12xz: Change the coding style of the previous commit.Lasse Collin1-5/+6
It isn't any better now but it's consistent with the rest of the code base.
2022-07-12xz: Avoid fchown(2) failure.Alexander Bluhm1-1/+7
OpenBSD does not allow to change the group of a file if the user does not belong to this group. In contrast to Linux, OpenBSD also fails if the new group is the same as the old one. Do not call fchown(2) in this case, it would change nothing anyway. This fixes an issue with Perl Alien::Build module. https://github.com/PerlAlien/Alien-Build/issues/62
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12liblzma: Use _MSVC_LANG to detect when "noexcept" can be used with MSVC.Lasse Collin1-1/+2
By default, MSVC always sets __cplusplus to 199711L. The real C++ standard version is available in _MSVC_LANG (or one could use /Zc:__cplusplus to set __cplusplus correctly). Fixes <https://sourceforge.net/p/lzmautils/discussion/708858/thread/f6bc3b108a/>. Thanks to Dan Weiss.
2022-07-12xzdiff: Update the man page about the exit status.Lasse Collin1-2/+2
This was forgotten from 194029ffaf74282a81f0c299c07f73caca3232ca.
2022-07-12xzless: Fix less(1) version detection when it contains a dot.Lasse Collin1-1/+1
Sometimes the version number from "less -V" contains a dot, sometimes not. xzless failed detect the version number when it does contain a dot. This fixes it. Thanks to nick87720z for reporting this. Apparently it had been reported here <https://bugs.gentoo.org/489362> in 2013.
2022-07-12xz: Document the special memlimit case of 2000 MiB on MIPS32.Lasse Collin1-2/+6
See commit 95806a8a52ae57bddf6c77dfd19cf7938a92e040.
2022-07-12Update THANKS.Lasse Collin1-0/+2
2022-07-12Reduce maximum possible memory limit on MIPS32Ivan A. Melnikov1-0/+6
Due to architectural limitations, address space available to a single userspace process on MIPS32 is limited to 2 GiB, not 4, even on systems that have more physical RAM -- e.g. 64-bit systems with 32-bit userspace, or systems that use XPA (an extension similar to x86's PAE). So, for MIPS32, we have to impose stronger memory limits. I've chosen 2000MiB to give the process some headroom.
2022-07-12CMake: Use interface library for better FindLibLZMA compatibility.Lasse Collin1-2/+9
https://www.mail-archive.com/xz-devel@tukaani.org/msg00446.html Thanks to Markus Rickert.
2022-07-12CMake: Try to improve compatibility with the FindLibLZMA module.Lasse Collin1-8/+13
The naming conflict with FindLibLZMA module gets worse. Not avoiding it in the first place was stupid. Normally find_package(LibLZMA) will use the module and find_package(liblzma 5.2.5 REQUIRED CONFIG) will use the config file even with a case insensitive file system. However, if CMAKE_FIND_PACKAGE_PREFER_CONFIG is TRUE and the file system is case insensitive, find_package(LibLZMA) will find our liblzma config file instead of using FindLibLZMA module. One big problem with this is that FindLibLZMA uses LibLZMA::LibLZMA and we use liblzma::liblzma as the target name. With target names CMake happens to be case sensitive. To workaround this, this commit adds add_library(LibLZMA::LibLZMA ALIAS liblzma::liblzma) to the config file. Then both spellings work. To make the behavior consistent between case sensitive and insensitive file systems, the config and related files are renamed from liblzmaConfig.cmake to liblzma-config.cmake style. With this style CMake looks for lowercase version of the package name so find_package(LiBLzmA 5.2.5 REQUIRED CONFIG) will work to find our config file. There are other differences between our config file and FindLibLZMA so it's still possible that things break for reasons other than the spelling of the target name. Hopefully those situations aren't too common. When the config file is available, it should always give as good or better results as FindLibLZMA so this commit doesn't affect the recommendation to use find_package(liblzma 5.2.5 REQUIRED CONFIG) which explicitly avoids FindLibLZMA. Thanks to Markus Rickert.
2022-07-12Tests: Add bad-1-lzma2-10.xz and also modify -9.xz.Lasse Collin3-2/+9
2022-07-12Tests: Add bad-1-lzma2-9.xz.Lasse Collin2-0/+4
2022-07-12Tests: Add bad-1-check-crc32-2.xz.Lasse Collin2-0/+7
2022-07-12Scripts: Add zstd support to xzdiff.Lasse Collin2-7/+15
2022-07-12Scripts: Fix exit status of xzgrep.Lasse Collin1-7/+13
Omit the -q option from xz, gzip, and bzip2. With xz this shouldn't matter. With gzip it's important because -q makes gzip replace SIGPIPE with exit status 2. With bzip2 it's important because with -q bzip2 is completely silent if input is corrupt while other decompressors still give an error message. Avoiding exit status 2 from gzip is important because bzip2 uses exit status 2 to indicate corrupt input. Before this commit xzgrep didn't recognize corrupt .bz2 files because xzgrep was treating exit status 2 as SIGPIPE for gzip compatibility. zstd still needs -q because otherwise it is noisy in normal operation. The code to detect real SIGPIPE didn't check if the exit status was due to a signal (>= 128) and so could ignore some other exit status too.
2022-07-12Scripts: Fix exit status of xzdiff/xzcmp.Lasse Collin1-14/+21
This is a minor fix since this affects only the situation when the files differ and the exit status is something else than 0. In such case there could be SIGPIPE from a decompression tool and that would result in exit status of 2 from xzdiff/xzcmp while the correct behavior would be to return 1 or whatever else diff or cmp may have returned. This commit omits the -q option from xz/gzip/bzip2/lzop arguments. I'm not sure why the -q was used in the first place, perhaps it hides warnings in some situation that I cannot see at the moment. Hopefully the removal won't introduce a new bug. With gzip the -q option was harmful because it made gzip return 2 instead of >= 128 with SIGPIPE. Ignoring exit status 2 (warning from gzip) isn't practical because bzip2 uses exit status 2 to indicate corrupt input file. It's better if SIGPIPE results in exit status >= 128. With bzip2 the removal of -q seems to be good because with -q it prints nothing if input is corrupt. The other tools aren't silent in this situation even with -q. On the other hand, if zstd support is added, it will need -q since otherwise it's noisy in normal situations. Thanks to Étienne Mollier and Sebastian Andrzej Siewior.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12liblzma: Enable Intel CET in x86 CRC assembly codesH.J. Lu2-0/+18
When Intel CET is enabled, we need to include <cet.h> in assembly codes to mark Intel CET support and add _CET_ENDBR to indirect jump targets. Tested on Intel Tiger Lake under CET enabled Linux.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12Build: Don't build bundles on Apple OSes.Lasse Collin1-0/+3
Thanks to Daniel Packard.
2022-07-12Update THANKS.Lasse Collin1-0/+1
2022-07-12Scripts: Add zstd support to xzgrep.Adam Borowski2-3/+7
Thanks to Adam Borowski.
2022-07-12CMake: Fix compatibility with CMake 3.13.Lasse Collin3-5/+5
The syntax "if(DEFINED CACHE{FOO})" requires CMake 3.14. In some other places the code treats the cache variables like normal variables already (${FOO} or if(FOO) is used, not ${CACHE{FOO}). Thanks to ygrek for reporting the bug on IRC.
2022-07-12Update THANKS.Lasse Collin1-1/+3
2022-07-12xz: Avoid unneeded \f escapes on the man page.Lasse Collin1-9/+22
I don't want to use \c in macro arguments but groff_man(7) suggests that \f has better portability. \f would be needed for the .TP strings for portability reasons anyway. Thanks to Bjarni Ingi Gislason.
2022-07-12xz: Use non-breaking spaces when intentionally using more than one space.Lasse Collin1-1/+1
This silences some style checker warnings. Seems that spaces in the beginning of a line don't need this treatment. Thanks to Bjarni Ingi Gislason.
2022-07-12xz: Protect the ellipsis (...) on the man page with \&.Lasse Collin1-2/+2
This does it only when ... appears outside macro calls. Thanks to Bjarni Ingi Gislason.
2022-07-12xz: Avoid the abbreviation "e.g." on the man page.Lasse Collin1-33/+33
A few are simply omitted, most are converted to "for example" and surrounded with commas. Sounds like that this is better style, for example, man-pages(7) recommends avoiding such abbreviations except in parenthesis. Thanks to Bjarni Ingi Gislason.
2022-07-12xz man page: Change \- (minus) to \(en (en-dash) for a numeric range.Lasse Collin1-8/+8
Docs of ancient troff/nroff mention \(em (em-dash) but not \(en and \- was used for both minus and en-dash. I don't know how portable \(en is nowadays but it can be changed back if someone complains. At least GNU groff and OpenBSD's mandoc support it. Thanks to Bjarni Ingi Gislason for the patch.
2022-07-12Windows: Fix building of resource files when config.h isn't used.Lasse Collin1-1/+3
Now CMake + Visual Studio works for building liblzma.dll. Thanks to Markus Rickert.
2022-07-12src/scripts/xzgrep.1: Filenames to xzgrep are optional.Lasse Collin1-1/+1
xzgrep --help was correct already.
2022-07-12Translations: Add Portuguese translation.Lasse Collin2-0/+1002
Jia Tan made white-space changes and also changed "Language: pt_BR\n" to pt. The translator wasn't reached so I'm hoping these changes are OK and will commit it without translator's approval. Thanks to Pedro Albuquerque and Jia Tan.
2022-07-12src/script/xzgrep.1: Remove superfluous '.RB'Bjarni Ingi Gislason1-6/+6
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z [ "test-groff" is a developmental version of "groff" ] Input file is ./src/scripts/xzgrep.1 <src/scripts/xzgrep.1>:20 (macro RB): only 1 argument, but more are expected <src/scripts/xzgrep.1>:23 (macro RB): only 1 argument, but more are expected <src/scripts/xzgrep.1>:26 (macro RB): only 1 argument, but more are expected <src/scripts/xzgrep.1>:29 (macro RB): only 1 argument, but more are expected <src/scripts/xzgrep.1>:32 (macro RB): only 1 argument, but more are expected "abc..." does not mean the same as "abc ...". The output from nroff and troff is unchanged except for the space between "file" and "...". Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2022-07-12xzgrep.1: Delete superfluous '.PP'Bjarni Ingi Gislason1-1/+0
Summary: mandoc -T lint xzgrep.1 : mandoc: xzgrep.1:79:2: WARNING: skipping paragraph macro: PP empty There is no change in the output of "nroff" and "troff". Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2022-07-12src/xz/xz.1: Correct misused two-fonts macrosBjarni Ingi Gislason1-5/+5
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z [ "test-groff" is a developmental version of "groff" ] Input file is ./src/xz/xz.1 <src/xz/xz.1>:408 (macro BR): only 1 argument, but more are expected <src/xz/xz.1>:1009 (macro BR): only 1 argument, but more are expected <src/xz/xz.1>:1743 (macro BR): only 1 argument, but more are expected <src/xz/xz.1>:1920 (macro BR): only 1 argument, but more are expected <src/xz/xz.1>:2213 (macro BR): only 1 argument, but more are expected Output from nroff and troff is unchanged, except for a font change of a full stop (.). Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2022-07-10Translations: Add Serbian translation.Lasse Collin2-0/+988
Quite a few white-space changes were made by Jia Tan to make this look good. Contacting the translator didn't succeed so I'm committing this without getting translator's approval. Thanks to Мирослав Николић (Miroslav Nikolic) and Jia Tan.
2022-07-04Translations: Add Swedish translation.Lasse Collin2-0/+984
Thanks to Sebastian Rasmussen and Jia Tan.
2022-07-04Translations: Add Esperanto translation.Lasse Collin2-0/+985
Thanks to Keith Bowes and Jia Tan.
2022-07-01Translations: Add Catalan translation.Lasse Collin2-0/+1077
Thanks to Jordi Mas and Jia Tan.
2022-06-30Translations: Add Ukrainian translation.Lasse Collin2-0/+997
Thanks to Yuri Chornoivan and Jia Tan.
2022-06-30Translators: Add Romanian translation.Lasse Collin2-0/+1017
Thanks to Remus-Gabriel Chelu and Jia Tan.
2022-06-29Translations: Update Brazilian Portuguese translation.Lasse Collin1-94/+92
One msgstr was changed. The diff is long due to changes in the source code line numbers in the comments. Thanks to Rafael Fontenelle.
2022-06-29Translations: Add Croatian translation.Lasse Collin2-0/+988
Thanks to Božidar Putanec and Jia Tan.
2022-06-29Translations: Add Spanish translation.Lasse Collin2-0/+985
Thanks to Cristian Othón Martínez Vera and Jia Tan.
2022-06-29Translations: Add Korean translation.Lasse Collin2-0/+973
Thanks to Seong-ho Cho and Jia Tan.
2020-03-23v5.2-specific typo fix from fossies.org.Lasse Collin1-1/+1
2020-03-23Typo fixes from fossies.org.Lasse Collin6-7/+7
https://fossies.org/linux/misc/xz-5.2.5.tar.xz/codespell.html
2020-03-17Bump version and soname for 5.2.5.larhzu/v5.2.5Lasse Collin2-2/+2
2020-03-17Update NEWS for 5.2.5.Lasse Collin1-0/+105
2020-03-16Translations: Rebuild cs.po to avoid incorrect fuzzy strings.Lasse Collin1-270/+322
"make dist" updates the .po files and the fuzzy strings would result in multiple very wrong translations.
2020-03-16README: Update outdated sections.Lasse Collin1-10/+11
2020-03-16README: Mention that translatable strings will change after 5.2.x.Lasse Collin1-71/+3
2020-03-16README: Mention that man pages can be translated.Lasse Collin1-3/+4
2020-03-16Translations: Add partial Danish translation.Lasse Collin2-0/+897
I made a few minor white space changes without getting them approved by the Danish translation team.
2020-03-16Update INSTALL.generic from Automake 1.16.1.Lasse Collin1-159/+162
2020-03-15Update INSTALL for Windows and DOS and add preliminary info for z/OS.Lasse Collin1-10/+41
2020-03-15Build: Update m4/ax_pthread.m4 from Autoconf Archive (again).Lasse Collin1-102/+117
2020-03-11xz: Never use thousand separators in DJGPP builds.Lasse Collin1-2/+12
DJGPP 2.05 added support for thousands separators but it's broken at least under WinXP with Finnish locale that uses a non-breaking space as the thousands separator. Workaround by disabling thousands separators for DJGPP builds.
2020-03-11DOS: Update dos/Makefile for DJGPP 2.05.Lasse Collin1-3/+1
It doesn't need -fgnu89-inline like 2.04beta did.
2020-03-11DOS: Update instructions in dos/INSTALL.txt.Lasse Collin1-30/+29
2020-03-11DOS: Update config.h.Lasse Collin1-0/+8
The added defines assume GCC >= 4.8.
2020-03-11Translations: Add hu, zh_CN, and zh_TW.Lasse Collin4-0/+2907
I made a few white space changes to these without getting them approved by the translation teams. (I tried to contact the hu and zh_TW teams but didn't succeed. I didn't contact the zh_CN team.)
2020-03-11Translations: Update vi.po to match the file from the TP.Lasse Collin1-228/+179
The translated strings haven't been updated but word wrapping is different.
2020-03-11Translations: Add fi and pt_BR, and update de, fr, it, and pl.Lasse Collin7-746/+2697
The German translation isn't identical to the file in the Translation Project but the changes (white space changes only) were approved by the translator Mario Blättermann.
2020-03-11Update THANKS.Lasse Collin1-0/+1
2020-03-11Build: Add very limited experimental CMake support.Lasse Collin7-0/+1174
This version matches CMake files in the master branch (commit 265daa873c0d871f5f23f9b56e133a6f20045a0a) except that this omits two source files that aren't in v5.2 and in the beginning of CMakeLists.txt the first paragraph in the comment is slightly different to point out possible issues in building shared liblzma.
2020-03-11Build: Add support for --no-po4a option to autogen.sh.Lasse Collin1-1/+10
Normally, if po4a isn't available, autogen.sh will return with non-zero exit status. The option --no-po4a can be useful when one knows that po4a isn't available but wants autogen.sh to still return with zero exit status.
2020-03-11Update m4/.gitignore.Lasse Collin1-0/+1
2020-03-11liblzma: Remove unneeded <sys/types.h> from fastpos_tablegen.c.Lasse Collin1-1/+0
This file only generates fastpos_table.c. It isn't built as a part of liblzma.
2020-03-11Use defined(__GNUC__) before __GNUC__ in preprocessor lines.Lasse Collin2-3/+5
This should silence the equivalent of -Wundef in compilers that don't define __GNUC__.
2020-03-11liblzma: Add more uses of lzma_memcmplen() to the normal mode of LZMA.Lasse Collin1-6/+10
This gives a tiny encoder speed improvement. This could have been done in 2014 after the commit 544aaa3d13554e8640f9caf7db717a96360ec0f6 but it was forgotten.
2020-03-11Build: Add visibility.m4 from gnulib.Lasse Collin2-1/+77
Appears that this file used to get included as a side effect of gettext. After the change to gettext version requirements this file no longer got copied to the package and so the build was broken.
2020-03-11xz: Silence a warning when sig_atomic_t is long int.Lasse Collin1-1/+1
It can be true at least on z/OS.
2020-03-11xz: Avoid unneeded access of a volatile variable.Lasse Collin1-1/+1
2020-03-11tuklib_integer.m4: Optimize the check order.Lasse Collin1-27/+29
The __builtin byteswapping is the preferred one so check for it first.
2020-03-11tuklib_exit: Add missing header.Lasse Collin1-0/+1
strerror() needs <string.h> which happened to be included via tuklib_common.h -> tuklib_config.h -> sysdefs.h if HAVE_CONFIG_H was defined. This wasn't tested without config.h before so it had worked fine.
2020-03-11sysdefs.h: Omit the conditionals around string.h and limits.h.Lasse Collin1-6/+2
string.h is used unconditionally elsewhere in the project and configure has always stopped if limits.h is missing, so these headers must have been always available even on the weirdest systems.
2020-03-11Build: Bump Autoconf and Libtool version requirements.Lasse Collin1-2/+2
There is no specific reason for this other than blocking the most ancient versions. These are still old: Autoconf 2.69 (2012) Automake 1.12 (2012) gettext 0.19.6 (2015) Libtool 2.4 (2010)
2020-03-11Build: Use AM_GNU_GETTEXT_REQUIRE_VERSION and require 0.19.6.Lasse Collin1-1/+5
This bumps the version requirement from 0.19 (from 2014) to 0.19.6 (2015). Using only the old AM_GNU_GETTEXT_VERSION results in old gettext infrastructure being placed in the package. By using both macros we get the latest gettext files while the other programs in the Autotools family can still see the old macro.
2020-03-11Translations: Add German translation of the man pages.Lasse Collin2-1/+5533
Thanks to Mario Blättermann.
2020-03-11Build: Add support for translated man pages using po4a.Lasse Collin8-45/+197
The dependency on po4a is optional. It's never required to install the translated man pages when xz is built from a release tarball. If po4a is missing when building from xz.git, the translated man pages won't be generated but otherwise the build will work normally. The translations are only updated automatically by autogen.sh and by "make mydist". This makes it easy to keep po4a as an optional dependency and ensures that I won't forget to put updated translations to a release tarball. The translated man pages aren't installed if --disable-nls is used. The installation of translated man pages abuses Automake internals by calling "install-man" with redefined dist_man_MANS and man_MANS. This makes the hairy script code slightly less hairy. If it breaks some day, this code needs to be fixed; don't blame Automake developers. Also, this adds more quotes to the existing shell script code in the Makefile.am "-hook"s.
2020-02-06Update THANKS (sync with the master branch).Lasse Collin1-0/+3
2020-02-06Update tests/.gitignore.Lasse Collin1-0/+4
2020-02-06Update m4/.gitignore.Lasse Collin1-0/+1
2020-02-06Update THANKS.Lasse Collin1-0/+1
2020-02-05xz: Comment out annoying sandboxing messages.Lasse Collin1-3/+7
2020-02-05Build: Workaround a POSIX shell detection problem on Solaris.Lasse Collin1-0/+10
I don't know if the problem is in gnulib's gl_POSIX_SHELL macro or if xzgrep does something that isn't in POSIX. The workaround adds a special case for Solaris: if /usr/xpg4/bin/sh exists and gl_cv_posix_shell wasn't overriden on the configure command line, use that shell for xzgrep and other scripts. That shell is known to work and exists on most Solaris systems.
2020-02-05Build: Update m4/ax_pthread.m4 from Autoconf Archive.Lasse Collin1-119/+279
2020-02-05xz: Limit --memlimit-compress to at most 4020 MiB for 32-bit xz.Lasse Collin2-2/+51
See the code comment for reasoning. It's far from perfect but hopefully good enough for certain cases while hopefully doing nothing bad in other situations. At presets -5 ... -9, 4020 MiB vs. 4096 MiB makes no difference on how xz scales down the number of threads. The limit has to be a few MiB below 4096 MiB because otherwise things like "xz --lzma2=dict=500MiB" won't scale down the dict size enough and xz cannot allocate enough memory. With "ulimit -v $((4096 * 1024))" on x86-64, the limit in xz had to be no more than 4085 MiB. Some safety margin is good though. This is hack but it should be useful when running 32-bit xz on a 64-bit kernel that gives full 4 GiB address space to xz. Hopefully this is enough to solve this: https://bugzilla.redhat.com/show_bug.cgi?id=1196786 FreeBSD has a patch that limits the result in tuklib_physmem() to SIZE_MAX on 32-bit systems. While I think it's not the way to do it, the results on --memlimit-compress have been good. This commit should achieve practically identical results for compression while leaving decompression and tuklib_physmem() and thus lzma_physmem() unaffected.
2020-02-05xz: Set the --flush-timeout deadline when the first input byte arrives.Lasse Collin3-7/+6
xz --flush-timeout=2000, old version: 1. xz is started. The next flush will happen after two seconds. 2. No input for one second. 3. A burst of a few kilobytes of input. 4. No input for one second. 5. Two seconds have passed and flushing starts. The first second counted towards the flush-timeout even though there was no pending data. This can cause flushing to occur more often than needed. xz --flush-timeout=2000, after this commit: 1. xz is started. 2. No input for one second. 3. A burst of a few kilobytes of input. The next flush will happen after two seconds counted from the time when the first bytes of the burst were read. 4. No input for one second. 5. No input for another second. 6. Two seconds have passed and flushing starts.
2020-02-05xz: Move flush_needed from mytime.h to file_pair struct in file_io.h.Lasse Collin5-9/+7
2020-02-05xz: coder.c: Make writing output a separate function.Lasse Collin1-13/+17
The same code sequence repeats so it's nicer as a separate function. Note that in one case there was no test for opt_mode != MODE_TEST, but that was only because that condition would always be true, so this commit doesn't change the behavior there.
2020-02-05xz: Fix semi-busy-waiting in xz --flush-timeout.Lasse Collin3-4/+19
When input blocked, xz --flush-timeout=1 would wake up every millisecond and initiate flushing which would have nothing to flush and thus would just waste CPU time. The fix disables the timeout when no input has been seen since the previous flush.
2020-02-05xz: Refactor io_read() a bit.Lasse Collin1-9/+8
2020-02-05xz: Update a comment in file_io.h.Lasse Collin1-1/+4
2020-02-05xz: Move the setting of flush_needed in file_io.c to a nicer location.Lasse Collin1-4/+2
2020-02-05xz: Enable Capsicum sandboxing by default if available.Lasse Collin2-10/+4
It has been enabled in FreeBSD for a while and reported to work fine. Thanks to Xin Li.
2019-12-31Rename unaligned_read32ne to read32ne, and similarly for the others.Lasse Collin15-62/+54
2019-12-31Rename read32ne to aligned_read32ne, and similarly for the others.Lasse Collin3-32/+32
Using the aligned methods requires more care to ensure that the address really is aligned, so it's nicer if the aligned methods are prefixed. The next commit will remove the unaligned_ prefix from the unaligned methods which in liblzma are used in more places than the aligned ones.
2019-12-31Revise tuklib_integer.h and .m4.Lasse Collin2-217/+314
Add a configure option --enable-unsafe-type-punning to get the old non-conforming memory access methods. It can be useful with old compilers or in some other less typical situations but shouldn't normally be used. Omit the packed struct trick for unaligned access. While it's best in some cases, this is simpler. If the memcpy trick doesn't work, one can request unsafe type punning from configure. Because CRC32/CRC64 code needs fast aligned reads, if no very safe way to do it is found, type punning is used as a fallback. This sucks but since it currently works in practice, it seems to be the least bad option. It's never needed with GCC >= 4.7 or Clang >= 3.6 since these support __builtin_assume_aligned and thus fast aligned access can be done with the memcpy trick. Other things: - Support GCC/Clang __builtin_bswapXX - Cleaner bswap fallback macros - Minor cleanups
2019-12-31Tests: Hopefully fix test_check.c to work on EBCDIC systems.Lasse Collin1-2/+7
Thanks to Daniel Richard G.
2019-12-31Scripts: Put /usr/xpg4/bin to the beginning of PATH on Solaris.Lasse Collin6-8/+65
This adds a configure option --enable-path-for-scripts=PREFIX which defaults to empty except on Solaris it is /usr/xpg4/bin to make POSIX grep and others available. The Solaris case had been documented in INSTALL with a manual fix but it's better to do this automatically since it is needed on most Solaris systems anyway. Thanks to Daniel Richard G.
2019-12-31Fix comment typos in tuklib_mbstr* files.Lasse Collin3-3/+3
2019-12-31Add missing include to tuklib_mbstr_width.c.Lasse Collin1-0/+1
It didn't matter in XZ Utils because sysdefs.h includes string.h anyway.
2019-12-31liblzma: Fix a buggy comment.Lasse Collin1-1/+1
2019-12-31configure.ac: Fix a typo in a comment.Lasse Collin1-1/+1
2019-12-31Tests: Silence warnings from clang -Wassign-enum.Lasse Collin2-2/+3
Also changed 999 to 99 so it fits even if lzma_check happened to be 8 bits wide.
2019-12-31liblzma: Add a comment.Lasse Collin1-1/+1
2019-12-31liblzma: Silence clang -Wmissing-variable-declarations.Lasse Collin2-0/+6
2019-12-31xz: Silence a warning from clang -Wsign-conversion in main.c.Lasse Collin1-1/+1
2019-12-31liblzma: Remove incorrect uses of lzma_attribute((__unused__)).Lasse Collin3-6/+3
Caught by clang -Wused-but-marked-unused.
2019-12-31Tests: Silence a warning from -Wsign-conversion.Lasse Collin1-4/+4
2019-12-31xz: Fix an integer overflow with 32-bit off_t.Lasse Collin1-2/+9
Or any off_t which isn't very big (like signed 64 bit integer that most system have). A small off_t could overflow if the file being decompressed had long enough run of zero bytes, which would result in corrupt output.
2019-12-31Tests: Remove a duplicate branch from tests/tests.h.Lasse Collin1-7/+2
The duplication was introduced about eleven years ago and should have been cleaned up back then already. This was caught by -Wduplicated-branches.
2019-12-31tuklib_mbstr_width: Fix a warning from -Wsign-conversion.Lasse Collin1-1/+1
2019-12-31xz: Fix some of the warnings from -Wsign-conversion.Lasse Collin7-13/+14
2019-12-31tuklib_cpucores: Silence warnings from -Wsign-conversion.Lasse Collin1-5/+5
2019-12-31xzdec: Fix warnings from -Wsign-conversion.Lasse Collin1-1/+1
2019-12-31liblzma: Fix warnings from -Wsign-conversion.Lasse Collin11-29/+31
Also, more parentheses were added to the literal_subcoder macro in lzma_comon.h (better style but no functional change in the current usage).
2019-12-31tuklib_integer: Silence warnings from -Wsign-conversion.Lasse Collin1-3/+3
2019-12-31tuklib_integer: Fix usage of conv macros.Lasse Collin1-4/+8
Use a temporary variable instead of e.g. conv32le(unaligned_read32ne(buf)) because the macro can evaluate its argument multiple times.
2019-12-31Update THANKS.Lasse Collin1-0/+1
2019-12-31liblzma: Fix comments.Lasse Collin6-7/+7
Thanks to Bruce Stark.
2019-12-31liblzma: Fix one more unaligned read to use unaligned_read16ne().Lasse Collin1-1/+1
2019-12-31Update THANKS.Lasse Collin1-0/+1
2019-12-31liblzma: memcmplen: Use ctz32() from tuklib_integer.h.Lasse Collin1-9/+1
The same compiler-specific #ifdefs are already in tuklib_integer.h
2019-12-31tuklib_integer: Cleanup MSVC-specific code.Lasse Collin1-11/+9
2019-12-31liblzma: Use unaligned_readXXne functions instead of type punning.Lasse Collin2-7/+7
Now gcc -fsanitize=undefined should be clean. Thanks to Jeffrey Walton.
2019-12-31tuklib_integer: Improve unaligned memory access.Lasse Collin1-12/+168
Now memcpy() or GNU C packed structs for unaligned access instead of type punning. See the comment in this commit for details. Avoiding type punning with unaligned access is needed to silence gcc -fsanitize=undefined. New functions: unaliged_readXXne and unaligned_writeXXne where XX is 16, 32, or 64.
2019-07-13liblzma: Avoid memcpy(NULL, foo, 0) because it is undefined behavior.Lasse Collin3-5/+23
I should have always known this but I didn't. Here is an example as a reminder to myself: int mycopy(void *dest, void *src, size_t n) { memcpy(dest, src, n); return dest == NULL; } In the example, a compiler may assume that dest != NULL because passing NULL to memcpy() would be undefined behavior. Testing with GCC 8.2.1, mycopy(NULL, NULL, 0) returns 1 with -O0 and -O1. With -O2 the return value is 0 because the compiler infers that dest cannot be NULL because it was already used with memcpy() and thus the test for NULL gets optimized out. In liblzma, if a null-pointer was passed to memcpy(), there were no checks for NULL *after* the memcpy() call, so I cautiously suspect that it shouldn't have caused bad behavior in practice, but it's hard to be sure, and the problematic cases had to be fixed anyway. Thanks to Jeffrey Walton.
2019-07-13Update THANKS.Lasse Collin1-0/+1
2019-07-13xz: Update xz man page date.Lasse Collin1-1/+1
2019-07-13spellingAntoine Cœur19-21/+21
2019-07-13README: Update translation instructions.Lasse Collin1-19/+13
XZ Utils is now part of the Translation Project <https://translationproject.org/>.
2019-07-13Update THANKS.Lasse Collin1-0/+1
2019-07-13xz: Fix a crash in progress indicator when in passthru mode.Lasse Collin3-7/+25
"xz -dcfv not_an_xz_file" crashed (all four options are required to trigger it). It caused xz to call lzma_get_progress(&strm, ...) when no coder was initialized in strm. In this situation strm.internal is NULL which leads to a crash in lzma_get_progress(). The bug was introduced when xz started using lzma_get_progress() to get progress info for multi-threaded compression, so the bug is present in versions 5.1.3alpha and higher. Thanks to Filip Palian <Filip.Palian@pjwstk.edu.pl> for the bug report.
2019-07-13xz: Update man page timestamp.Lasse Collin1-1/+1
2019-07-13'have have' typosPavel Raiskup2-2/+2
2019-07-13xzless: Rename unused variables to silence static analysers.Lasse Collin1-1/+1
In this particular case I don't see this affecting readability of the code. Thanks to Pavel Raiskup.
2019-07-13liblzma: Remove an always-true condition from lzma_index_cat().Lasse Collin1-2/+2
This should help static analysis tools to see that newg isn't leaked. Thanks to Pavel Raiskup.
2019-07-13liblzma: Improve lzma_properties_decode() API documentation.Lasse Collin1-3/+4
2019-05-01Update THANKS.Lasse Collin1-0/+1
2019-05-01Windows: Update VS version in windows/vs2019/config.h.Lasse Collin1-1/+1
2019-05-01Windows: Upgrade solution itselfJulien Marrec1-2/+5
2019-05-01Windows: Upgrade solution with VS2019Julien Marrec2-14/+16
2019-05-01Windows: Duplicate windows/vs2017 before upgradingJulien Marrec4-0/+933
2019-05-01Windows/VS2017: Omit WindowsTargetPlatformVersion from project files.Lasse Collin3-2/+4
I understood that if a WTPV is specified, it's often wrong because different VS installations have different SDK version installed. Omitting the WTPV tag makes VS2017 default to Windows SDK 8.1 which often is also missing, so in any case people may need to specify the WTPV before building. But some day in the future a missing WTPV tag will start to default to the latest installed SDK which sounds reasonable: https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html Thanks to "dom".
2018-04-29Bump version and soname for 5.2.4.larhzu/v5.2.4Lasse Collin2-2/+2
2018-04-29extra/scanlzma: Fix compiler warnings.Lasse Collin1-1/+5
2018-04-29Add NEWS for 5.2.4.Lasse Collin1-0/+27
2018-03-28Update THANKS.Lasse Collin1-0/+2
2018-03-28nothrow: use noexcept for C++11 and newerBen Boeckel1-1/+5
In C++11, the `throw()` specifier is deprecated and `noexcept` is preffered instead.
2018-03-28liblzma: Remove incorrect #ifdef from range_common.h.Lasse Collin1-3/+1
In most cases it was harmless but it could affect some custom build systems. Thanks to Pippijn van Steenhoven.
2018-03-28Update THANKS.Lasse Collin1-0/+1
2018-03-28tuklib_integer: New Intel C compiler needs immintrin.h.Lasse Collin1-0/+11
Thanks to Melanie Blower (Intel) for the patch.
2018-03-28Update THANKS.Lasse Collin1-0/+1
2018-03-28Windows: Fix paths in VS project files.Lasse Collin4-36/+36
Some paths use slashes instead of backslashes as directory separators... now it should work (I tested VS2013 version).
2018-03-28Windows: Add project files for VS2017.Lasse Collin4-0/+935
These files match the v5.2 branch (no file info decoder).
2018-03-28Windows: Move VS2013 files into windows/vs2013 directory.Lasse Collin4-279/+279
2018-03-28Fix or hide warnings from GCC 7's -Wimplicit-fallthrough.Lasse Collin2-0/+8
2018-03-28Docs: Fix a typo in a comment in doc/examples/02_decompress.c.Alexey Tourbin1-1/+1
2018-03-28xz: Fix "xz --list --robot missing_or_bad_file.xz".Lasse Collin1-2/+6
It ended up printing an uninitialized char-array when trying to print the check names (column 7) on the "totals" line. This also changes the column 12 (minimum xz version) to 50000002 (xz 5.0.0) instead of 0 when there are no valid input files. Thanks to kidmin for the bug report.
2018-03-28Build: Omit pre-5.0.0 entries from the generated ChangeLog.Lasse Collin1-1/+2
It makes ChangeLog significantly smaller.
2018-03-28Update the Git repository URL to HTTPS in ChangeLog.Lasse Collin1-1/+1
2018-03-28Update the home page URLs to HTTPS.Lasse Collin10-14/+14
2017-03-30xz: Use POSIX_FADV_RANDOM for in "xz --list" mode.Lasse Collin1-2/+8
xz --list is random access so POSIX_FADV_SEQUENTIAL was clearly wrong.