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
This commit is contained in:
Ingo Klöcker 2024-03-11 13:53:18 +01:00
parent 47f3d92bf3
commit 7158397c09
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9

View File

@ -37,6 +37,9 @@ typedef struct
{ {
struct _gpgme_op_import_result result; 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 /* A pointer to the next pointer of the last import status in the
list. This makes appending new imports painless while preserving list. This makes appending new imports painless while preserving
the order. */ the order. */
@ -309,6 +312,17 @@ _gpgme_import_status_handler (void *priv, gpgme_status_code_t code, char *args)
opd->lastp = &(*opd->lastp)->next; opd->lastp = &(*opd->lastp)->next;
break; 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: default:
break; break;
} }