From 7158397c098b8527c97c6bf350c2ebd6c0012594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 11 Mar 2024 13:53:18 +0100 Subject: [PATCH] core: Check STATUS_FAILURE in import operations. * src/import.c (op_data_t): Add failure_code. (_gpgme_import_status_handler): Set it. Return it on EOF. -- GnuPG-bug-id: 7036 --- src/import.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/import.c b/src/import.c index f46313c7..f288a811 100644 --- a/src/import.c +++ b/src/import.c @@ -37,6 +37,9 @@ typedef struct { struct _gpgme_op_import_result result; + /* The error code from a FAILURE status line or 0. */ + gpg_error_t failure_code; + /* A pointer to the next pointer of the last import status in the list. This makes appending new imports painless while preserving the order. */ @@ -309,6 +312,17 @@ _gpgme_import_status_handler (void *priv, gpgme_status_code_t code, char *args) opd->lastp = &(*opd->lastp)->next; 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; + + case GPGME_STATUS_EOF: + if (opd->failure_code) + return opd->failure_code; + break; + default: break; }