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

View File

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

View File

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

View File

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

View File

@ -150,6 +150,8 @@ keylist_status_handler (void *priv, gpgme_status_code_t code, char *args)
break;
case GPGME_STATUS_FAILURE:
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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