core: Preserve more specific existing failure code

* src/decrypt.c (_gpgme_decrypt_status_handler): Ignore received failure
code if we already have a specific failure code.
* src/encrypt.c (_gpgme_encrypt_status_handler): Ditto.
* src/export.c (export_status_handler): Ditto.
* src/genkey.c (genkey_status_handler): Ditto.
* src/keylist.c (keylist_status_handler): Ditto.
* src/keysign.c (keysign_status_handler): Ditto.
* src/passwd.c (passwd_status_handler): Ditto.
* src/revsig.c (revsig_status_handler): Ditto.
* src/setexpire.c (setexpire_status_handler): Ditto.
* src/sign.c (_gpgme_sign_status_handler): Ditto.
* src/tofupolicy.c (tofu_policy_status_handler): Ditto.
* src/verify.c (_gpgme_verify_status_handler): Ditto.
--

Usually, a process emits at most one failure code. But some operations
like the creation of an encrypted archive involve multiple chained
processes, so that multiple failure codes can be received. We want to
keep the first specific failure code we received. Further failure codes
are only parsed if we received just an unspecific "general error" so
far.

GnuPG-bug-id: 6575
This commit is contained in:
Ingo Klöcker 2023-11-14 13:48:48 +01:00
parent 1bfd5e92d0
commit 77e982579c
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
12 changed files with 36 additions and 12 deletions

View File

@ -377,7 +377,9 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
switch (code)
{
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -126,7 +126,9 @@ _gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code,
switch (code)
{
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -116,7 +116,9 @@ export_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
default:

View File

@ -172,7 +172,9 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -150,7 +150,9 @@ keylist_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
if (opd->failure_code && !strcmp (args, "option-parser")
&& gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
err = gpg_error (GPG_ERR_INV_ENGINE);

View File

@ -113,7 +113,9 @@ keysign_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -97,7 +97,9 @@ passwd_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -101,7 +101,9 @@ revsig_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -96,7 +96,9 @@ setexpire_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -363,7 +363,9 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -97,7 +97,9 @@ tofu_policy_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF:

View File

@ -1055,7 +1055,9 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
return parse_error (sig, args, !!sig );
case GPGME_STATUS_FAILURE:
opd->failure_code = _gpgme_parse_failure (args);
if (!opd->failure_code
|| gpg_err_code (opd->failure_code) == GPG_ERR_GENERAL)
opd->failure_code = _gpgme_parse_failure (args);
break;
case GPGME_STATUS_EOF: