summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* tuklib_integer.h: Reverts previous commit.Jia Tan2023-05-041-2/+2
| | | | | Previous commit 6be460dde07113fe3f08f814b61ddc3264125a96 would cause an error if the integer size was 32 bit.
* tuklib_integer.h: Changes two other UINT_MAX == UINT32_MAX to >=.Jia Tan2023-05-041-2/+2
|
* tuklib_integer.h: Fix a recent copypaste error in Clang detection.Lasse Collin2023-05-031-2/+2
| | | | | | Wrong line was changed in 7062348bf35c1e4cbfee00ad9fffb4a21aa6eff7. Also, this has >= instead of == since ints larger than 32 bits would work too even if not relevant in practice.
* Windows: Include <intrin.h> when needed.Jia Tan2023-04-192-0/+16
| | | | | | | | | | Legacy Windows did not need to #include <intrin.h> to use the MSVC intrinsics. Newer versions likely just issue a warning, but the MSVC documentation says to include the header file for the intrinsics we use. GCC and Clang can "pretend" to be MSVC on Windows, so extra checks are needed in tuklib_integer.h to only include <intrin.h> when it will is actually needed.
* tuklib_integer: Use __builtin_clz() with Clang.Jia Tan2023-04-191-3/+3
| | | | | | | | | Clang has support for __builtin_clz(), but previously Clang would fallback to either the MSVC intrinsic or the regular C code. This was discovered due to a bug where a new version of Clang required the <intrin.h> header file in order to use the MSVC intrinsics. Thanks to Anton Kochkov for notifying us about the bug.
* liblzma: Update project maintainers in lzma.h.Lasse Collin2023-04-141-1/+1
| | | | AUTHORS was updated earlier, lzma.h was simply forgotten.
* liblzma: Cleans up old commented out code.Jia Tan2023-04-131-11/+0
|
* Build: Removes redundant check for LZMA1 filter support.Jia Tan2023-03-231-4/+1
|
* liblzma: Silence -Wsign-conversion in SSE2 code in memcmplen.h.Lasse Collin2023-03-191-1/+2
| | | | | Thanks to Christian Hesse for reporting the issue. Fixes: https://github.com/tukaani-project/xz/issues/44
* Change a few HTTP URLs to HTTPS.Lasse Collin2023-03-183-6/+6
| | | | The xz man page timestamp was intentionally left unchanged.
* liblzma: Remove note from lzma_options_bcj about the ARM64 exception.Jia Tan2023-03-171-1/+1
| | | | | This was left in by mistake since an early version of the ARM64 filter used a different struct for its options.
* liblzma: Add set lzma.h as the main page for Doxygen documentation.Jia Tan2023-03-1715-29/+2
| | | | | | | | | | | | | | | | | | The \mainpage command is used in the first block of comments in lzma.h. This changes the previously nearly empty index.html to use the first comment block in lzma.h for its contents. lzma.h is no longer documented separately, but this is for the better since lzma.h only defined a few macros that users do not need to use. The individual API header files all have a disclaimer that they should not be #included directly, so there should be no confusion on the fact that lzma.h should be the only header used by applications. Additionally, the note "See ../lzma.h for information about liblzma as a whole." was removed since lzma.h is now the main page of the generated HTML and does not have its own page anymore. So it would be confusing in the HTML version and was only a "nice to have" when browsing the source files.
* liblzma: Defines masks for return values from lzma_index_checks().Jia Tan2023-03-131-0/+23
|
* xz: Simplify the error-label in Capsicum sandbox code.Lasse Collin2023-03-111-15/+12
| | | | | | Also remove unneeded "sandbox_allowed = false;" as this code will never be run more than once (making it work with multiple input files isn't trivial).
* xz: Make Capsicum sandbox more strict with stdin and stdout.Lasse Collin2023-03-081-0/+8
|
* Revert: "Add warning if Capsicum sandbox system calls are unsupported."Jia Tan2023-03-081-6/+4
| | | | | | The warning causes the exit status to be 2, so this will cause problems for many scripted use cases for xz. The sandbox usage is already very limited already, so silently disabling this allows it to be more usable.
* xz: Fix -Wunused-label in io_sandbox_enter().Jia Tan2023-03-071-2/+2
| | | | Thanks to Xin Li for recommending the fix.
* xz: Add warning if Capsicum sandbox system calls are unsupported.Jia Tan2023-03-061-0/+2
| | | | | The warning is only used when errno == ENOSYS. Otherwise, xz still issues a fatal error.
* xz: Skip Capsicum sandbox system calls when they are unsupported.Jia Tan2023-03-061-5/+17
| | | | | | If a system has the Capsicum header files but does not actually implement the system calls, then this would render xz unusable. Instead, we can check if errno == ENOSYS and not issue a fatal error.
* xz: Reorder cap_enter() to beginning of capsicum sandbox code.Jia Tan2023-03-061-3/+3
| | | | | | cap_enter() puts the process into the sandbox. If later calls to cap_rights_limit() fail, then the process can still have some extra protections.
* liblzma: Clarify lzma_lzma_preset() documentation in lzma12.h.Jia Tan2023-03-011-0/+5
| | | | | | | | | | | lzma_lzma_preset() does not guarentee that the lzma_options_lzma are usable in an encoder even if it returns false (success). If liblzma is built with default configurations, then the options will always be usable. However if the match finders hc3, hc4, or bt4 are disabled, then the options may not be usable depending on the preset level requested. The documentation was updated to reflect this complexity, since this behavior was unclear before.
* liblzma: Replace '\n' -> newline in filter.h documentation.Jia Tan2023-02-241-1/+1
| | | | | The '\n' renders as a newline when the comments are converted to html by Doxygen.
* liblzma: Shorten return description for two functions in filter.h.Jia Tan2023-02-241-6/+2
| | | | | Shorten the description for lzma_raw_encoder_memusage() and lzma_raw_decoder_memusage().
* liblzma: Reword a few lines in filter.hJia Tan2023-02-241-5/+5
|
* liblzma: Improve documentation in filter.h.Jia Tan2023-02-241-83/+143
| | | | | | | | | | All functions now explicitly specify parameter and return values. The notes and code annotations were moved before the parameter and return value descriptions for consistency. Also, the description above lzma_filter_encoder_is_supported() about not being able to list available filters was removed since lzma_str_list_filters() will do this.
* liblzma: Avoid null pointer + 0 (undefined behavior in C).Lasse Collin2023-02-2310-23/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the C99 and C17 standards, section 6.5.6 paragraph 8 means that adding 0 to a null pointer is undefined behavior. As of writing, "clang -fsanitize=undefined" (Clang 15) diagnoses this. However, I'm not aware of any compiler that would take advantage of this when optimizing (Clang 15 included). It's good to avoid this anyway since compilers might some day infer that pointer arithmetic implies that the pointer is not NULL. That is, the following foo() would then unconditionally return 0, even for foo(NULL, 0): void bar(char *a, char *b); int foo(char *a, size_t n) { bar(a, a + n); return a == NULL; } In contrast to C, C++ explicitly allows null pointer + 0. So if the above is compiled as C++ then there is no undefined behavior in the foo(NULL, 0) call. To me it seems that changing the C standard would be the sane thing to do (just add one sentence) as it would ensure that a huge amount of old code won't break in the future. Based on web searches it seems that a large number of codebases (where null pointer + 0 occurs) are being fixed instead to be future-proof in case compilers will some day optimize based on it (like making the above foo(NULL, 0) return 0) which in the worst case will cause security bugs. Some projects don't plan to change it. For example, gnulib and thus many GNU tools currently require that null pointer + 0 is defined: https://lists.gnu.org/archive/html/bug-gnulib/2021-11/msg00000.html https://www.gnu.org/software/gnulib/manual/html_node/Other-portability-assumptions.html In XZ Utils null pointer + 0 issue should be fixed after this commit. This adds a few if-statements and thus branches to avoid null pointer + 0. These check for size > 0 instead of ptr != NULL because this way bugs where size > 0 && ptr == NULL will likely get caught quickly. None of them are in hot spots so it shouldn't matter for performance. A little less readable version would be replacing ptr + offset with offset != 0 ? ptr + offset : ptr or creating a macro for it: #define my_ptr_add(ptr, offset) \ ((offset) != 0 ? ((ptr) + (offset)) : (ptr)) Checking for offset != 0 instead of ptr != NULL allows GCC >= 8.1, Clang >= 7, and Clang-based ICX to optimize it to the very same code as ptr + offset. That is, it won't create a branch. So for hot code this could be a good solution to avoid null pointer + 0. Unfortunately other compilers like ICC 2021 or MSVC 19.33 (VS2022) will create a branch from my_ptr_add(). Thanks to Marcin Kowalczyk for reporting the problem: https://github.com/tukaani-project/xz/issues/36
* liblzma: Adjust container.h for consistency with filter.h.Jia Tan2023-02-231-11/+9
|
* liblzma: Fix small typos and reword a few things in filter.h.Jia Tan2023-02-231-7/+6
|
* liblzma: Convert list of flags in lzma_mt to bulleted list.Jia Tan2023-02-231-3/+6
|
* liblzma: Fix typo in documentation in container.hJia Tan2023-02-231-1/+1
| | | | lzma_microlzma_decoder -> lzma_microlzma_encoder
* liblzma: Improve documentation for container.hJia Tan2023-02-231-53/+93
| | | | | | Standardizing each function to always specify parameters and return values. Also moved the parameters and return values to the end of each function description.
* liblzma: Very minor API doc tweaks.Lasse Collin2023-02-164-14/+14
| | | | | | | | | | Use "member" to refer to struct members as that's the term used by the C standard. Use lzma_options_delta.dist and such in docs so that in Doxygen's HTML output they will link to the doc of the struct member. Clean up a few trailing white spaces too.
* liblzma: Adjust spacing in doc headers in bcj.h.Jia Tan2023-02-171-7/+7
|
* liblzma: Adjust documentation in bcj.h for consistent style.Jia Tan2023-02-171-21/+22
|
* liblzma: Rename field => member in documentation.Jia Tan2023-02-177-95/+95
| | | | Also adjusted preset value => preset level.
* liblzma: Silence a warning from MSVC.Lasse Collin2023-02-161-1/+1
| | | | | | | | It gives C4146 here since unary minus with unsigned integer is still unsigned (which is the intention here). Doing it with substraction makes it clearer and avoids the warning. Thanks to Nathan Moinvaziri for reporting this.
* liblzma: Improve documentation for stream_flags.hJia Tan2023-02-161-30/+46
| | | | | | | | Standardizing each function to always specify parameters and return values. Also moved the parameters and return values to the end of each function description. A few small things were reworded and long sentences broken up.
* liblzma: Improve documentation in lzma12.h.Jia Tan2023-02-151-9/+23
| | | | All functions now explicitly specify parameter and return values.
* liblzma: Improve documentation in check.h.Jia Tan2023-02-151-13/+28
| | | | | | All functions now explicitly specify parameter and return values. Also moved the note about SHA-256 functions not being exported to the top of the file.
* liblzma: Improve documentation in index.hJia Tan2023-02-151-51/+126
| | | | All functions now explicitly specify parameter and return values.
* liblzma: Reword a comment in index.h.Jia Tan2023-02-151-2/+2
|
* liblzma: Omit lzma_index_iter's internal field from Doxygen docs.Jia Tan2023-02-151-1/+8
| | | | | Add \private above this field and its sub-fields since it is not meant to be modified by users.
* liblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.Jia Tan2023-02-141-1/+1
| | | | | LZMA_MEMLIMIT_ERROR was missing the "<" character needed to put documentation after a member.
* liblzma: Improve documentation for base.h.Jia Tan2023-02-141-5/+25
| | | | | Standardizing each function to always specify params and return values. Also fixed a small grammar mistake.
* liblzma: Add one more missing [out] annotation in vli.hJia Tan2023-02-141-1/+1
|
* liblzma: Minor improvements to vli.h.Jia Tan2023-02-141-6/+7
| | | | | Added [out] annotations to parameters that are pointers and can have their value changed. Also added a clarification to lzma_vli_is_valid.
* liblzma: Add comments for macros in delta.h.Jia Tan2023-02-101-0/+8
| | | | | Document LZMA_DELTA_DIST_MIN and LZMA_DELTA_DIST_MAX for completeness and to avoid Doxygen warnings.
* liblzma: Improve documentation in index_hash.h.Jia Tan2023-02-101-9/+27
| | | | | All functions now explicitly specify parameter and return values. Also reworded the description of lzma_index_hash_init() for readability.
* xz: Improve the comment about start_time in mytime.c.Lasse Collin2023-02-071-5/+10
| | | | | | start_time is relative to an arbitary point in time, it's not time of day, so using it for anything else than time differences wouldn't make sense.
* xz: Add a comment clarifying the use of start_time in mytime.c.Jia Tan2023-02-041-0/+5
|