From 8fb23094c2f520e346170fe64d8b9b2e27e8dd64 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 26 Jan 2022 12:47:56 +0100 Subject: gpgconf: Fix --list-options for forced options * tools/gpgconf-comp.c (retrieve_options_from_program): Ignore to to ignored options. Add failsafe code to avoid calling percent_escape with NULL. -- Remember: When using ARGPARSE_FLAG_WITHATTR the ARGPARSE_OPT_IGNORE flags in the returned type needs to be considered. GnuPG-bug-id: 5800 --- tools/gpgconf-comp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c index 5a393732d..b8ed050ce 100644 --- a/tools/gpgconf-comp.c +++ b/tools/gpgconf-comp.c @@ -2071,6 +2071,8 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed) /* pargs.r_type? pargs.r.ret_str: "[cmdline]"); */ continue; } + if ((pargs.r_type & ARGPARSE_OPT_IGNORE)) + continue; /* We only have the short option. Search in the option table * for the long option name. */ @@ -2111,7 +2113,10 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed) opt_value = xasprintf ("%lu", pargs.r.ret_ulong); break; case ARGPARSE_TYPE_STRING: - opt_value = xasprintf ("\"%s", gc_percent_escape (pargs.r.ret_str)); + if (!pargs.r.ret_str) + opt_value = xstrdup ("\"(none)"); /* We should not see this. */ + else + opt_value = xasprintf ("\"%s", gc_percent_escape (pargs.r.ret_str)); break; default: /* ARGPARSE_TYPE_NONE or any unknown type. */ opt_value = xstrdup ("1"); /* Make sure we have some value. */ -- cgit v1.2.3