Better detection for signature creation failure.

This commit is contained in:
Werner Koch 2009-08-06 19:09:10 +00:00
parent 0fcf3ee915
commit 35b25decde
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@
(sign_init_result): .. new. Init new fields. (sign_init_result): .. new. Init new fields.
(sign_start): Use sign_init_result. (sign_start): Use sign_init_result.
(_gpgme_sign_status_handler): Take care of the new INV_SGNR. (_gpgme_sign_status_handler): Take care of the new INV_SGNR.
Return an error if no signature has been created.
2009-07-07 Werner Koch <wk@g10code.com> 2009-07-07 Werner Koch <wk@g10code.com>

View File

@ -50,6 +50,7 @@ typedef struct
/* Flags used while processing the status lines. */ /* Flags used while processing the status lines. */
unsigned int ignore_inv_recp:1; unsigned int ignore_inv_recp:1;
unsigned int inv_sgnr_seen:1; unsigned int inv_sgnr_seen:1;
unsigned int sig_created_seen:1;
} *op_data_t; } *op_data_t;
@ -262,6 +263,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
switch (code) switch (code)
{ {
case GPGME_STATUS_SIG_CREATED: case GPGME_STATUS_SIG_CREATED:
opd->sig_created_seen = 1;
err = parse_sig_created (args, opd->last_sig_p); err = parse_sig_created (args, opd->last_sig_p);
if (err) if (err)
return err; return err;
@ -285,7 +287,9 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
case GPGME_STATUS_EOF: case GPGME_STATUS_EOF:
if (opd->result.invalid_signers) if (opd->result.invalid_signers)
return gpg_error (GPG_ERR_UNUSABLE_SECKEY); err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
else if (!opd->sig_created_seen)
err = gpg_error (GPG_ERR_GENERAL);
break; break;
default: default:
@ -323,6 +327,7 @@ sign_init_result (gpgme_ctx_t ctx, int ignore_inv_recp)
opd->last_sig_p = &opd->result.signatures; opd->last_sig_p = &opd->result.signatures;
opd->ignore_inv_recp = !!ignore_inv_recp; opd->ignore_inv_recp = !!ignore_inv_recp;
opd->inv_sgnr_seen = 0; opd->inv_sgnr_seen = 0;
opd->sig_created_seen = 0;
return 0; return 0;
} }