From d8e6d1e9ed7d181f546426269ab7b04e184bb9a1 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 25 Jan 2022 19:05:16 +0100 Subject: [PATCH] common: Fix returning of option attributes for options with args. * common/argparse.c (gnupg_argparse): Set attribute flags -- GnuPG-bug-id: 5799 This is a backport from the fix in libgpg-error in case gnupg 2.2 is build against an older version of libgpg-error. --- common/argparse.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/argparse.c b/common/argparse.c index fb2bc6556..b63f800e8 100644 --- a/common/argparse.c +++ b/common/argparse.c @@ -1344,6 +1344,17 @@ gnupg_argparse (estream_t fp, gnupg_argparse_t *arg, gnupg_opt_t *opts_orig) xfree (buffer); else gpgrt_annotate_leaked_object (buffer); + /* If the caller wants us to return the attributes or + * ignored options, or these flags in. */ + if ((arg->flags & ARGPARSE_FLAG_WITHATTR)) + { + if (opts[idx].ignore) + arg->r_type |= ARGPARSE_ATTR_IGNORE; + if (opts[idx].forced) + arg->r_type |= ARGPARSE_ATTR_FORCE; + if (set_ignore) + arg->r_type |= ARGPARSE_OPT_IGNORE; + } } } goto leave;