[balsa] Decrypt RFC 3156 signatures.



commit 9e753ded076a7600630cda6065ceea4b6e72a49c
Author: Albrecht Dreß <albrecht dress arcor de>
Date:   Tue Oct 18 09:34:27 2016 -0400

    Decrypt RFC 3156 signatures.
    
        Usually, RFC 3156 (PGP/MIME) signature parts
        (application/pgp-signature, see RFC 3156, sect. 9.2.) should
        never be encoded as they are 7-bit clean.  However, there are
        implementations which apply an (superfluous) encoding to such
        parts, which Balsa fails to interpret properly.  The attached
        patch fixes this behaviour, and as a side effect plugs a gmime
        stream leak when checking a S/MIME signature which is always
        encoded.
    
        * libbalsa/gmime-multipart-crypt.c (g_mime_gpgme_mps_verify):
        always decrypt the signature; do not leak sigstream.
    
    Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>

 ChangeLog                        |   14 ++++++++++++++
 libbalsa/gmime-multipart-crypt.c |   11 +++--------
 2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a66d582..49a1302 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2016-10-18  Albrecht Dreß
+
+       Usually, RFC 3156 (PGP/MIME) signature parts
+       (application/pgp-signature, see RFC 3156, sect. 9.2.) should
+       never be encoded as they are 7-bit clean.  However, there are
+       implementations which apply an (superfluous) encoding to such
+       parts, which Balsa fails to interpret properly.  The attached
+       patch fixes this behaviour, and as a side effect plugs a gmime
+       stream leak when checking a S/MIME signature which is always
+       encoded.
+
+       * libbalsa/gmime-multipart-crypt.c (g_mime_gpgme_mps_verify):
+       always decrypt the signature; do not leak sigstream.
+
 2016-10-03  Albrecht Dreß
 
        Implement the 'AUTH PLAIN' SASL mechanism for POP3
diff --git a/libbalsa/gmime-multipart-crypt.c b/libbalsa/gmime-multipart-crypt.c
index c7b2244..1e1dd3d 100644
--- a/libbalsa/gmime-multipart-crypt.c
+++ b/libbalsa/gmime-multipart-crypt.c
@@ -284,16 +284,10 @@ g_mime_gpgme_mps_verify(GMimeMultipartSigned * mps, GError ** error)
     /* get the signature stream */
     wrapper = g_mime_part_get_content_object(GMIME_PART(signature));
 
-    /* FIXME: temporary hack for Balsa to support S/MIME,
-     * ::verify() should probably take a mime part so it can
-     * decode this itself if it needs to. */
-    if (crypto_prot == GPGME_PROTOCOL_CMS) {
+    /* a s/mime signature is always encoded, a pgp signature shouldn't,
+     * but there exist implementations which encode it... */
        sigstream = g_mime_stream_mem_new();
        g_mime_data_wrapper_write_to_stream(wrapper, sigstream);
-    } else {
-       sigstream = g_mime_data_wrapper_get_stream(wrapper);
-    }
-
     g_mime_stream_reset(sigstream);
 
     /* verify the signature */
@@ -301,6 +295,7 @@ g_mime_gpgme_mps_verify(GMimeMultipartSigned * mps, GError ** error)
        libbalsa_gpgme_verify(stream, sigstream, crypto_prot, FALSE,
                              error);
     g_object_unref(stream);
+    g_object_unref(sigstream);
 
     return result;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]