From 349a69b5ea77c334c1c59b56f283bb65dc54a590 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 20 Sep 2023 12:05:41 +0200 Subject: [PATCH] core: Check STATUS_FAILURE in export operations. * src/export.c (op_data_t): Add failure_code. (export_status_handler): Set it. (gpgme_op_export_ext, gpgme_op_export_keys): Also check the failure code. -- That is just in case we missed an error code. For example with older gpg versions (e.g. 2.3.8) and exporting to a keyserver. --- src/export.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/export.c b/src/export.c index 155085ff..d5137866 100644 --- a/src/export.c +++ b/src/export.c @@ -35,7 +35,12 @@ /* Local operation data. */ typedef struct { - gpg_error_t err; /* Error encountered during the export. */ + /* The error code from a FAILURE status line or 0. */ + gpg_error_t failure_code; + + /* Error encountered during the export. */ + gpg_error_t err; + } *op_data_t; @@ -110,6 +115,10 @@ export_status_handler (void *priv, gpgme_status_code_t code, char *args) opd->err = err; break; + case GPGME_STATUS_FAILURE: + opd->failure_code = _gpgme_parse_failure (args); + break; + default: break; } @@ -356,7 +365,7 @@ gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[], err = _gpgme_op_data_lookup (ctx, OPDATA_EXPORT, &hook, -1, NULL); opd = hook; if (!err) - err = opd->err; + err = opd->err ? opd->err : opd->failure_code; } } @@ -501,7 +510,7 @@ gpgme_op_export_keys (gpgme_ctx_t ctx, err = _gpgme_op_data_lookup (ctx, OPDATA_EXPORT, &hook, -1, NULL); opd = hook; if (!err) - err = opd->err; + err = opd->err ? opd->err : opd->failure_code; } }