From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: David Bremner <david@tethera.net>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH v4 2/4] util/repair: identify and repair "Mixed Up" mangled messages
Date: Sun, 15 Sep 2019 03:37:09 -0400 [thread overview]
Message-ID: <87ftky104a.fsf@fifthhorseman.net> (raw)
In-Reply-To: <871rwj1vwc.fsf@tethera.net>
[-- Attachment #1: Type: text/plain, Size: 3001 bytes --]
Thanks for the review, David.
On Fri 2019-09-13 22:58:27 -0300, David Bremner wrote:
> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>
>> +/* see
>> + * https://tools.ietf.org/html/draft-dkg-openpgp-pgpmime-message-mangling-00#section-4.1.1 */
>> +static bool
>> +_notmuch_is_mixed_up_mangled (GMimeObject *part)
>> +{
>> + GMimeMultipart *mpart = NULL;
>> + GMimeObject *first, *second, *third = NULL;
>> + char *prelude_string = NULL;
>> + bool prelude_is_empty;
>> +
>> + if (! g_mime_content_type_is_type (g_mime_object_get_content_type (part),
>> + "multipart", "mixed"))
>> + return false;
>
> Can g_mime_object_get_content_type plausibly fail (and return NULL) here?
hm, yes, it can -- if it's passed NULL, for example. It's not an
external function, but I can program this more defensively. i'll do
that in the next revision.
>> + if (! GMIME_IS_MULTIPART (part))
>> + return false;
>
> I guess this happens if the mime structure does not match the content
> type declaration? Not sure if this needs a comment or if it's clear
> enough.
yeah, this is unlikely, maybe even impossible given the current gmime
implementation, but it's a defensive step.
>> + mpart = GMIME_MULTIPART (part);
>> + if (mpart == NULL)
>> + return false;
>> + if (g_mime_multipart_get_count (mpart) != 3)
>> + return false;
>> + first = g_mime_multipart_get_part (mpart, 0);
>
> there's a slight cognitive dissonance for me between the zero and one
> based indexing schemes here. part0, part1, and part2? or maybe an
> GMimeObject *part[3]
sure, i'll make it *parts[3] to avoid the dissonance. ("part" is already
taken -- it's the argument for the function.
>> + if (! g_mime_content_type_is_type (g_mime_object_get_content_type (first),
>> + "text", "plain"))
>> + return false;
>> + if (! GMIME_IS_TEXT_PART (first))
>> + return false;
>> + second = g_mime_multipart_get_part (mpart, 1);
>> + if (! g_mime_content_type_is_type (g_mime_object_get_content_type (second),
>> + "application", "pgp-encrypted"))
>> + return false;
>> + third = g_mime_multipart_get_part (mpart, 2);
>> + if (! g_mime_content_type_is_type (g_mime_object_get_content_type (third),
>> + "application", "octet-stream"))
>> + return false;
>> +
>> + /* Is first subpart length 0? */
>> + prelude_string = g_mime_text_part_get_text (GMIME_TEXT_PART (first));
>> + prelude_is_empty = ! (strcmp ("", prelude_string));
>> + g_free (prelude_string);
>
> It might make sense to use the EMPTY_STRING macro here, although
> currently it's only accesible via notmuch-private.h
hm, notmuch-private.h is in lib/, which seems inappropriate for use
outside the library. however, i agree that this seems like a
superfluous call to strcmp -- i'll change it for a simple test.
I've updated this 2/4 patch on my mixed-up-mangling branch (visible at
https://gitlab.com/dkg/notmuch), and i'll send it to this thread
shortly.
--dkg
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
next prev parent reply other threads:[~2019-09-15 7:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-09 3:27 v4 of repairing Mixed-up mangled MIME messages Daniel Kahn Gillmor
2019-09-09 3:27 ` [PATCH v4 1/4] test: add test for "Mixed-Up Mime" message mangling Daniel Kahn Gillmor
2019-09-09 3:27 ` [PATCH v4 2/4] util/repair: identify and repair "Mixed Up" mangled messages Daniel Kahn Gillmor
2019-09-14 1:58 ` David Bremner
2019-09-15 7:37 ` Daniel Kahn Gillmor [this message]
2019-09-15 7:38 ` [PATCH v5 " Daniel Kahn Gillmor
2019-09-15 20:26 ` Tomi Ollila
2019-09-15 23:09 ` Daniel Kahn Gillmor
2019-09-09 3:27 ` [PATCH v4 3/4] index: repair "Mixed Up" messages before indexing Daniel Kahn Gillmor
2019-09-09 3:27 ` [PATCH v4 4/4] cli/{show, reply}: use repaired form of "Mixed Up" mangled messages Daniel Kahn Gillmor
[not found] ` <87zhj5xcet.fsf@tethera.net>
2019-09-16 10:49 ` David Bremner
2019-09-17 5:59 ` Daniel Kahn Gillmor
2019-09-17 23:36 ` David Bremner
2019-09-14 7:29 ` v4 of repairing Mixed-up mangled MIME messages Jameson Graef Rollins
2019-09-14 11:30 ` David Bremner
2019-09-14 16:08 ` Jameson Graef Rollins
2019-09-14 17:33 ` David Bremner
2019-09-15 3:05 ` Daniel Kahn Gillmor
2019-09-14 17:54 ` Daniel Kahn Gillmor
2019-09-14 23:58 ` Jameson Graef Rollins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ftky104a.fsf@fifthhorseman.net \
--to=dkg@fifthhorseman.net \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).