xz: Fix getopt_long argument type in --filters*

Forgetting the argument (or not using = to separate the option from
the argument) resulted in lzma_str_to_filters() being called with NULL
as input string argument. The function handles it fine but xz passes
the NULL to printf() too:

    $ xz --filters
    xz: Error in --filters=FILTERS option:
    xz: (null)
    xz: ^
    xz: Unexpected NULL pointer argument(s) to lzma_str_to_filters()

Now it's correct:

    $ xz --filters
    xz: option '--filters' requires an argument

The --filters-help option doesn't take any arguments.

Fixes: 9ded880a02
Fixes: d6af7f3470
Fixes: a165d7df19
This commit is contained in:
Lasse Collin 2025-01-05 11:40:34 +02:00
parent 2655c81b5e
commit 52ff324337
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
1 changed files with 11 additions and 11 deletions

View File

@ -275,17 +275,17 @@ parse_real(args_info *args, int argc, char **argv)
{ "best", no_argument, NULL, '9' }, { "best", no_argument, NULL, '9' },
// Filters // Filters
{ "filters", optional_argument, NULL, OPT_FILTERS}, { "filters", required_argument, NULL, OPT_FILTERS},
{ "filters1", optional_argument, NULL, OPT_FILTERS1}, { "filters1", required_argument, NULL, OPT_FILTERS1},
{ "filters2", optional_argument, NULL, OPT_FILTERS2}, { "filters2", required_argument, NULL, OPT_FILTERS2},
{ "filters3", optional_argument, NULL, OPT_FILTERS3}, { "filters3", required_argument, NULL, OPT_FILTERS3},
{ "filters4", optional_argument, NULL, OPT_FILTERS4}, { "filters4", required_argument, NULL, OPT_FILTERS4},
{ "filters5", optional_argument, NULL, OPT_FILTERS5}, { "filters5", required_argument, NULL, OPT_FILTERS5},
{ "filters6", optional_argument, NULL, OPT_FILTERS6}, { "filters6", required_argument, NULL, OPT_FILTERS6},
{ "filters7", optional_argument, NULL, OPT_FILTERS7}, { "filters7", required_argument, NULL, OPT_FILTERS7},
{ "filters8", optional_argument, NULL, OPT_FILTERS8}, { "filters8", required_argument, NULL, OPT_FILTERS8},
{ "filters9", optional_argument, NULL, OPT_FILTERS9}, { "filters9", required_argument, NULL, OPT_FILTERS9},
{ "filters-help", optional_argument, NULL, OPT_FILTERS_HELP}, { "filters-help", no_argument, NULL, OPT_FILTERS_HELP},
{ "lzma1", optional_argument, NULL, OPT_LZMA1 }, { "lzma1", optional_argument, NULL, OPT_LZMA1 },
{ "lzma2", optional_argument, NULL, OPT_LZMA2 }, { "lzma2", optional_argument, NULL, OPT_LZMA2 },