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.
This commit is contained in:
Werner Koch 2023-09-20 12:05:41 +02:00
parent 8fde9cbe22
commit e35400bd69
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -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;
}
}