summaryrefslogtreecommitdiffstats
path: root/crypt-gpgme.c
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2013-10-23 11:11:25 -0700
committerMichael Elkins <me@sigpipe.org>2013-10-23 11:11:25 -0700
commitfa7134e8152a069268af4ffe84d540b844b0764e (patch)
tree82d0d5224a09b7c3290f23afe142bcc897487add /crypt-gpgme.c
parent91734ad42787d709dab81217f13e8225846cda02 (diff)
Ensure that at least one signature was generated to catch the case where $pgp_sign_as is unset and no default key is specified in ~/.gnupg/gpg.conf
closes #3658
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r--crypt-gpgme.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index accb7279..8cbe7ff4 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -818,6 +818,7 @@ static BODY *sign_message (BODY *a, int use_smime)
char buf[100];
gpgme_ctx_t ctx;
gpgme_data_t message, signature;
+ gpgme_sign_result_t sigres;
convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
@@ -859,6 +860,17 @@ static BODY *sign_message (BODY *a, int use_smime)
mutt_error (_("error signing data: %s\n"), gpgme_strerror (err));
return NULL;
}
+ /* Check for zero signatures generated. This can occur when $pgp_sign_as is
+ * unset and there is no default key specified in ~/.gnupg/gpg.conf
+ */
+ sigres = gpgme_op_sign_result (ctx);
+ if (!sigres->signatures)
+ {
+ gpgme_data_release (signature);
+ gpgme_release (ctx);
+ mutt_error (_("$pgp_sign_as unset and no default key specified in ~/.gnupg/gpg.conf"));
+ return NULL;
+ }
sigfile = data_object_to_tempfile (signature, NULL);
gpgme_data_release (signature);