Skip to content

Commit

Permalink
liblzma: lzma_str_to_filters: Set *error_pos on all errors
Browse files Browse the repository at this point in the history
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: cedeeca
  • Loading branch information
Larhzu committed Apr 22, 2024
1 parent ed8e552 commit 70d12dd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/liblzma/common/string_conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,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()";
Expand Down

0 comments on commit 70d12dd

Please sign in to comment.