]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: lzma_str_to_filters: Set *error_pos on all errors
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 22 Apr 2024 18:54:39 +0000 (21:54 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 21 May 2024 21:12:07 +0000 (00:12 +0300)
The API docs clearly say that if error_pos isn't NULL then *error
is always set on any error. However, it wasn't touched if str == NULL
or filters == NULL or unsupported flags were specified.

Fixes: cedeeca2ea6ada5b0411b2ae10d7a859e837f203
(cherry picked from commit 70d12dd069bb9bb0d6bb1c8fafc4e6f77780263d)

src/liblzma/common/string_conversion.c

index 92ad4a07bbe60c14c052fca3db1b9b857f25c07d..73e7ae3a1ea947d94c9b69f4ed05a9a67d5fff3e 100644 (file)
@@ -996,6 +996,12 @@ extern LZMA_API(const char *)
 lzma_str_to_filters(const char *str, int *error_pos, lzma_filter *filters,
                uint32_t flags, const lzma_allocator *allocator)
 {
+       // If error_pos isn't NULL, *error_pos must always be set.
+       // liblzma <= 5.4.6 and <= 5.6.1 have a bug and don't do this
+       // when str == NULL or filters == NULL or flags are unsupported.
+       if (error_pos != NULL)
+               *error_pos = 0;
+
        if (str == NULL || filters == NULL)
                return "Unexpected NULL pointer argument(s) "
                                "to lzma_str_to_filters()";