diff options
| author | NIIBE Yutaka <[email protected]> | 2026-03-18 06:26:10 +0100 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2026-03-18 06:26:10 +0100 |
| commit | 8b89678aed6dcc87eff15c9a468b3e8a6a8600d0 (patch) | |
| tree | 48ed766503a3371256712f217d21ef31da86c27f /src/passphrase.c | |
| parent | Handle the case when pinentry is invoked multiple times. (diff) | |
| download | gpgme-8b89678aed6dcc87eff15c9a468b3e8a6a8600d0.tar.gz gpgme-8b89678aed6dcc87eff15c9a468b3e8a6a8600d0.zip | |
Fix passphrase cancel handling.
* src/passphrase.c (op_data_t): Add "canceled" field.
(_gpgme_passphrase_status_handler): Mark "canceled" when it sees
GPGME_STATUS_CANCELED_BY_USER. Reset at
GPGME_STATUS_PINENTRY_LAUNCHED. Return GPG_ERR_CANCELED when
"canceled" is marked at GPGME_STATUS_EOF.
--
GnuPG-bug-id: 8172
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src/passphrase.c')
| -rw-r--r-- | src/passphrase.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/passphrase.c b/src/passphrase.c index d07afa91..56de8f94 100644 --- a/src/passphrase.c +++ b/src/passphrase.c @@ -37,10 +37,11 @@ typedef struct { + int bad_passphrase; + int canceled; int no_passphrase; char *uid_hint; char *passphrase_info; - int bad_passphrase; char *maxlen; } *op_data_t; @@ -89,11 +90,13 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code, case GPGME_STATUS_BAD_PASSPHRASE: opd->bad_passphrase++; + opd->canceled = 0; opd->no_passphrase = 0; break; case GPGME_STATUS_GOOD_PASSPHRASE: opd->bad_passphrase = 0; + opd->canceled = 0; opd->no_passphrase = 0; break; @@ -112,16 +115,21 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code, break; case GPGME_STATUS_CANCELED_BY_USER: - return gpg_error (GPG_ERR_CANCELED); + opd->canceled = 1; + break; case GPGME_STATUS_PINENTRY_LAUNCHED: /* Another pinentry is invoked, reset the passphrase status. */ - opd->no_passphrase = opd->bad_passphrase = 0; + opd->bad_passphrase = 0; + opd->canceled = 0; + opd->no_passphrase = 0; break; case GPGME_STATUS_EOF: if (opd->no_passphrase || opd->bad_passphrase) return gpg_error (GPG_ERR_BAD_PASSPHRASE); + else if (opd->canceled) + return gpg_error (GPG_ERR_CANCELED); break; case GPGME_STATUS_ERROR: |
