1 Return-Path: <cworth@cworth.org>
\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 68062431FBF;
\r
6 Sat, 21 Nov 2009 19:12:39 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id ON4On8Rt7+Gv; Sat, 21 Nov 2009 19:12:38 -0800 (PST)
\r
11 Received: from cworth.org (localhost [127.0.0.1])
\r
12 by olra.theworths.org (Postfix) with ESMTP id 00D23431FAE;
\r
13 Sat, 21 Nov 2009 19:12:37 -0800 (PST)
\r
14 From: Carl Worth <cworth@cworth.org>
\r
15 To: Mike Hommey <mh+notmuch@glandium.org>
\r
16 In-Reply-To: <20091121222615.GA4925@glandium.org>
\r
17 References: <20091120132625.GA19246@glandium.org>
\r
18 <87y6m0lxym.fsf@yoom.home.cworth.org>
\r
19 <20091120210556.GA25421@glandium.org>
\r
20 <20091121222615.GA4925@glandium.org>
\r
21 Date: Sun, 22 Nov 2009 04:12:26 +0100
\r
22 Message-ID: <87k4xj2qxx.fsf@yoom.home.cworth.org>
\r
24 Content-Type: text/plain; charset=us-ascii
\r
25 Cc: notmuch@notmuchmail.org
\r
26 Subject: Re: [notmuch] Segfault with weird Message-ID
\r
27 X-BeenThere: notmuch@notmuchmail.org
\r
28 X-Mailman-Version: 2.1.12
\r
30 List-Id: "Use and development of the notmuch mail system."
\r
31 <notmuch.notmuchmail.org>
\r
32 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
33 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
34 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
35 List-Post: <mailto:notmuch@notmuchmail.org>
\r
36 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
37 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
39 X-List-Received-Date: Sun, 22 Nov 2009 03:12:39 -0000
\r
41 On Sat, 21 Nov 2009 23:26:15 +0100, Mike Hommey <mh+notmuch@glandium.org> wrote:
\r
42 > I just was able to reproduce after starting over.
\r
44 Thanks Mike. I was able to reproduce this as well by eliminating the
\r
45 spurious blank line I had on the 2nd or 3rd line. (So maybe that managed
\r
46 to sneak in when you sent me the message.)
\r
48 > header isn't "", and message_id is correctly filled. I can also confirm
\r
49 > the exception is thrown from notmuch->xapian_db->add_document.
\r
51 Yes. We were trying to add a term that is too long for Xapian. I've
\r
52 fixed this by simply falling back to our existing sha-1 code when a
\r
55 Thanks so much for the bug report!
\r
59 commit 5d56e931b99d575dbb0b936d24aae5e9903861ad
\r
60 Author: Carl Worth <cworth@cworth.org>
\r
61 Date: Sun Nov 22 04:03:49 2009 +0100
\r
63 add_message: Use sha-1 in place of overly long message ID.
\r
65 Since Xapian has a limit on the maximum length of a term, we have
\r
66 to check for that before trying to add the message ID as a term.
\r
68 This fixes the bug reported by Mike Hommey here:
\r
70 <20091120132625.GA19246@glandium.org>
\r
72 I've also constructed 20 files with a range of message ID lengths
\r
73 centered around the Xapian term-length limit which I'll use to seed a
\r
74 new test suite soon.
\r
76 diff --git a/lib/database.cc b/lib/database.cc
\r
77 index 169dc5e..f4a445a 100644
\r
78 --- a/lib/database.cc
\r
79 +++ b/lib/database.cc
\r
80 @@ -892,7 +892,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
82 const char *date, *header;
\r
83 const char *from, *to, *subject;
\r
85 + char *message_id = NULL;
\r
88 *message_ret = NULL;
\r
89 @@ -937,11 +937,20 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
90 header = notmuch_message_file_get_header (message_file, "message-id");
\r
91 if (header && *header != '\0') {
\r
92 message_id = _parse_message_id (message_file, header, NULL);
\r
94 /* So the header value isn't RFC-compliant, but it's
\r
95 * better than no message-id at all. */
\r
96 if (message_id == NULL)
\r
97 message_id = talloc_strdup (message_file, header);
\r
100 + /* Reject a Message ID that's too long. */
\r
101 + if (message_id && strlen (message_id) + 1 > NOTMUCH_TERM_MAX) {
\r
102 + talloc_free (message_id);
\r
103 + message_id = NULL;
\r
107 + if (message_id == NULL ) {
\r
108 /* No message-id at all, let's generate one by taking a
\r
109 * hash over the file's contents. */
\r
110 char *sha1 = notmuch_sha1_of_file (filename);
\r