[PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal.

Jameson Graef Rollins jrollins at finestructure.net
Sat Dec 10 13:19:21 PST 2011


On Fri,  9 Dec 2011 14:54:26 -0500, Austin Clements <amdragon at MIT.EDU> wrote:
> +    /* Handle PGP/MIME parts */
> +    if (GMIME_IS_MULTIPART_ENCRYPTED (part) && out->ctx->decrypt) {
> +	if (out->children != 2) {
> +	    /* this violates RFC 3156 section 4, so we won't bother with it. */
> +	    fprintf (stderr, "Error: %d part(s) for a multipart/encrypted "
> +		     "message (should be exactly 2)\n",
> +		     out->children);
> +	} else {
> +	    out->is_encrypted = TRUE;

As per Dmitry's previous point, maybe it's better to do something like:

if (GMIME_IS_MULTIPART_ENCRYPTED (part)) {
    out->is_encrypted = TRUE;
    if (out->ctx->decrypt) {
        if (out->children != 2) {
...

And similarly for is_signed.

> +	    GMimeMultipartEncrypted *encrypteddata =
> +		GMIME_MULTIPART_ENCRYPTED (part);
> +	    out->decrypted_child = g_mime_multipart_encrypted_decrypt
> +		(encrypteddata, out->ctx->cryptoctx, &err);
> +	    if (out->decrypted_child) {
> +		out->decrypt_success = TRUE;
> +		out->is_signed = TRUE;
> +		out->sig_validity = g_mime_multipart_encrypted_get_signature_validity (encrypteddata);

Encrypted messages are not necessarily signed, so we need to be careful
about setting is_signed = TRUE based just on decryption status.  The
problem is that gmime's handling of this stuff (at least last I looked
in 2.4) is not so good.
g_mime_multipart_encrypted_get_signature_validity () should return
GMIME_SIGNATURE_STATUS_UNKNOWN if there's no signature, so I think
is_signed should be set TRUE only if sig_validity is not UNKNOWN.

I've really been meaning to overhaul this stuff for gmime 2.6.
Hopefully I'll start looking at that after these patches go through.

jamie.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20111210/5d5b4372/attachment.pgp>


More information about the notmuch mailing list