From eeba9a9ba9262d820b448ce680b1e7c9c5c13ff4 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Thu, 22 Mar 2018 09:32:31 -0700 Subject: [PATCH] Fix s/mime non-detached signature handling. This fix is based on stbuehler's patch from https://dev.gnupg.org/T2919. Recent versions of gpgme seem to terminate the connection for a protocol error. stbuehler's analysis is that this is actually a gpgme bug, but recreating the context works around the problem. --- crypt-gpgme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 7283e109..03cf7f0d 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -1685,9 +1685,9 @@ static BODY *decrypt_part (BODY *a, STATE *s, FILE *fpout, int is_smime, if (r_is_signed) *r_is_signed = 0; +restart: ctx = create_gpgme_context (is_smime); - restart: /* Make a data object from the body, create context etc. */ ciphertext = file_to_data_object (s->fpin, a->offset, a->length); if (!ciphertext) @@ -1730,6 +1730,9 @@ static BODY *decrypt_part (BODY *a, STATE *s, FILE *fpout, int is_smime, { maybe_signed = 1; gpgme_data_release (plaintext); + /* We release the context because recent versions of gpgme+gpgsm + * appear to end the session after an error */ + gpgme_release (ctx); goto restart; } } -- 2.50.1