unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Do not segfault on empty mime parts
@ 2010-03-02 15:31 martin f. krafft
  2010-04-13 15:55 ` Carl Worth
  0 siblings, 1 reply; 2+ messages in thread
From: martin f. krafft @ 2010-03-02 15:31 UTC (permalink / raw)
  To: notmuch; +Cc: martin f. krafft

notmuch previously unconditionally checked mime parts for various
properties, but not for NULL, which is the case if libgmime encounters
an empty mime part.

Upon encounter of an empty mime part, the following is printed to
stderr (the second line due to my patch):

  (process:17197): gmime-CRITICAL **: g_mime_message_get_mime_part: assertion `GMIME_IS_MESSAGE (message)' failed
  Warning: Not indexing empty mime part.

This is probably a bug that should get addressed in libgmime, but for
not, my patch is an acceptable workaround.

Signed-off-by: martin f. krafft <madduck@madduck.net>
---
 lib/index.cc |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index cf93025..0d6640b 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -336,6 +336,11 @@ _index_mime_part (notmuch_message_t *message,
     GMimeContentDisposition *disposition;
     char *body;
 
+    if (! part) {
+	fprintf (stderr, "Warning: Not indexing empty mime part.\n");
+	return;
+    }
+
     if (GMIME_IS_MULTIPART (part)) {
 	GMimeMultipart *multipart = GMIME_MULTIPART (part);
 	int i;
-- 
1.7.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Do not segfault on empty mime parts
  2010-03-02 15:31 [PATCH] Do not segfault on empty mime parts martin f. krafft
@ 2010-04-13 15:55 ` Carl Worth
  0 siblings, 0 replies; 2+ messages in thread
From: Carl Worth @ 2010-04-13 15:55 UTC (permalink / raw)
  To: martin f. krafft, notmuch; +Cc: martin f. krafft

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

On Tue,  2 Mar 2010 16:31:28 +0100, "martin f. krafft" <madduck@madduck.net> wrote:
> notmuch previously unconditionally checked mime parts for various
> properties, but not for NULL, which is the case if libgmime encounters
> an empty mime part.

Thanks for the fix.

> Upon encounter of an empty mime part, the following is printed to
> stderr (the second line due to my patch):
> 
>   (process:17197): gmime-CRITICAL **: g_mime_message_get_mime_part: assertion `GMIME_IS_MESSAGE (message)' failed
>   Warning: Not indexing empty mime part.

That message is all quite ugly. I'm perpetually annoyed by libraries
that claim to detect major problems, (even "CRITICAL" problems!), and
just print messages and march along.

Either there *is* a critical problem here, in which case the library
should halt after printing the message, (see for example, what notmuch
does with its INTERNAL_ERROR macro), or there's no problem at all and
the code should operate correctly without these obnoxious messages.

Anyway, I've put a note into TODO that we should do the following (in
order):

  1. Add a test case to trigger this message

  2. File a bug against GMime to eliminate its portion of the message

  3. Remove the notmuch portion of the message

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-13 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-02 15:31 [PATCH] Do not segfault on empty mime parts martin f. krafft
2010-04-13 15:55 ` Carl Worth

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).