From 52ff32433734d03befd85a5bf00fba77d6501455 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Sun, 5 Jan 2025 11:40:34 +0200 Subject: [PATCH] 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: 9ded880a0221f4d1256845fc4ab957ffd377c760 Fixes: d6af7f347077b22403133239592e478931307759 Fixes: a165d7df1964121eb9df715e6f836a31c865beef --- src/xz/args.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/xz/args.c b/src/xz/args.c index e85d1526..83706dbf 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -275,17 +275,17 @@ parse_real(args_info *args, int argc, char **argv) { "best", no_argument, NULL, '9' }, // Filters - { "filters", optional_argument, NULL, OPT_FILTERS}, - { "filters1", optional_argument, NULL, OPT_FILTERS1}, - { "filters2", optional_argument, NULL, OPT_FILTERS2}, - { "filters3", optional_argument, NULL, OPT_FILTERS3}, - { "filters4", optional_argument, NULL, OPT_FILTERS4}, - { "filters5", optional_argument, NULL, OPT_FILTERS5}, - { "filters6", optional_argument, NULL, OPT_FILTERS6}, - { "filters7", optional_argument, NULL, OPT_FILTERS7}, - { "filters8", optional_argument, NULL, OPT_FILTERS8}, - { "filters9", optional_argument, NULL, OPT_FILTERS9}, - { "filters-help", optional_argument, NULL, OPT_FILTERS_HELP}, + { "filters", required_argument, NULL, OPT_FILTERS}, + { "filters1", required_argument, NULL, OPT_FILTERS1}, + { "filters2", required_argument, NULL, OPT_FILTERS2}, + { "filters3", required_argument, NULL, OPT_FILTERS3}, + { "filters4", required_argument, NULL, OPT_FILTERS4}, + { "filters5", required_argument, NULL, OPT_FILTERS5}, + { "filters6", required_argument, NULL, OPT_FILTERS6}, + { "filters7", required_argument, NULL, OPT_FILTERS7}, + { "filters8", required_argument, NULL, OPT_FILTERS8}, + { "filters9", required_argument, NULL, OPT_FILTERS9}, + { "filters-help", no_argument, NULL, OPT_FILTERS_HELP}, { "lzma1", optional_argument, NULL, OPT_LZMA1 }, { "lzma2", optional_argument, NULL, OPT_LZMA2 },