[notmuch] [PATCH] Do not segfault on empty mime parts
[notmuch-archives.git] / ca / 67df3a4306648594d806acc5f17957abd450d8
1 Return-Path: <madduck@piper.oerlikon.madduck.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 210E0431FBD\r
6         for <notmuch@notmuchmail.org>; Tue,  2 Mar 2010 07:54:21 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.599\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-2.599] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id b7Cp5IyLNkzT for <notmuch@notmuchmail.org>;\r
16         Tue,  2 Mar 2010 07:54:15 -0800 (PST)\r
17 Received: from clegg.madduck.net (clegg.madduck.net [193.242.105.96])\r
18         by olra.theworths.org (Postfix) with ESMTP id BA6B3431FAE\r
19         for <notmuch@notmuchmail.org>; Tue,  2 Mar 2010 07:54:15 -0800 (PST)\r
20 Received: from piper.oerlikon.madduck.net (unknown\r
21         [IPv6:2001:1620:f02:0:211:2fff:fe6b:c869])\r
22         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
23         (Client CN "piper.oerlikon.madduck.net",\r
24         Issuer "CAcert Class 3 Root" (verified OK))\r
25         by clegg.madduck.net (postfix) with ESMTPS id 31E271D40D0;\r
26         Tue,  2 Mar 2010 16:54:00 +0100 (CET)\r
27 Received: by piper.oerlikon.madduck.net (Postfix, from userid 1000)\r
28         id 366F7C0; Tue,  2 Mar 2010 16:31:33 +0100 (CET)\r
29 From: "martin f. krafft" <madduck@madduck.net>\r
30 To: notmuch@notmuchmail.org\r
31 Date: Tue,  2 Mar 2010 16:31:28 +0100\r
32 Message-Id: <1267543888-18134-1-git-send-email-madduck@madduck.net>\r
33 X-Mailer: git-send-email 1.7.0\r
34 X-Virus-Scanned: clamav-milter 0.95.3 at clegg\r
35 X-Virus-Status: Clean\r
36 Cc: "martin f. krafft" <madduck@madduck.net>\r
37 Subject: [notmuch] [PATCH] Do not segfault on empty mime parts\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Tue, 02 Mar 2010 15:54:21 -0000\r
51 \r
52 notmuch previously unconditionally checked mime parts for various\r
53 properties, but not for NULL, which is the case if libgmime encounters\r
54 an empty mime part.\r
55 \r
56 Upon encounter of an empty mime part, the following is printed to\r
57 stderr (the second line due to my patch):\r
58 \r
59   (process:17197): gmime-CRITICAL **: g_mime_message_get_mime_part: assertion `GMIME_IS_MESSAGE (message)' failed\r
60   Warning: Not indexing empty mime part.\r
61 \r
62 This is probably a bug that should get addressed in libgmime, but for\r
63 not, my patch is an acceptable workaround.\r
64 \r
65 Signed-off-by: martin f. krafft <madduck@madduck.net>\r
66 ---\r
67  lib/index.cc |    5 +++++\r
68  1 files changed, 5 insertions(+), 0 deletions(-)\r
69 \r
70 diff --git a/lib/index.cc b/lib/index.cc\r
71 index cf93025..0d6640b 100644\r
72 --- a/lib/index.cc\r
73 +++ b/lib/index.cc\r
74 @@ -336,6 +336,11 @@ _index_mime_part (notmuch_message_t *message,\r
75      GMimeContentDisposition *disposition;\r
76      char *body;\r
77  \r
78 +    if (! part) {\r
79 +       fprintf (stderr, "Warning: Not indexing empty mime part.\n");\r
80 +       return;\r
81 +    }\r
82 +\r
83      if (GMIME_IS_MULTIPART (part)) {\r
84         GMimeMultipart *multipart = GMIME_MULTIPART (part);\r
85         int i;\r
86 -- \r
87 1.7.0\r
88 \r