1 Return-Path: <morgan.veyret@gmail.com>
\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 arlo.cworth.org (Postfix) with ESMTP id B7FF46DE02B1
\r
6 for <notmuch@notmuchmail.org>; Mon, 8 Jun 2015 11:41:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.729 tagged_above=-999 required=5 tests=[AWL=0.090,
\r
12 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001,
\r
13 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,
\r
14 RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled
\r
15 Received: from arlo.cworth.org ([127.0.0.1])
\r
16 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id 7qZtRctZlEjo for <notmuch@notmuchmail.org>;
\r
18 Mon, 8 Jun 2015 11:41:40 -0700 (PDT)
\r
19 Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com
\r
21 by arlo.cworth.org (Postfix) with ESMTPS id 5B1236DE02D2
\r
22 for <notmuch@notmuchmail.org>; Mon, 8 Jun 2015 11:41:40 -0700 (PDT)
\r
23 Received: by ykfl8 with SMTP id l8so56277649ykf.1
\r
24 for <notmuch@notmuchmail.org>; Mon, 08 Jun 2015 11:41:38 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
\r
27 :content-type; bh=hLsFt/ZtgTpTp2w8HaK0QiawoCwdSLoFDHjTc8BHBEk=;
\r
28 b=wb9BRcHF0D69Gy3nVTfTWuqDnwldGVmcgBVwBCICUwUP9eJi8K3GUlZHhABgvOeKJC
\r
29 ehH95WomIq6qS72QedC/9oyA+PNIlU5rRJvVVzGSKOvgCql304pnVpLLlWsTmE/pWZc3
\r
30 hJK+5XWR9xyg24us/VjD2OerVxxn7gSmTeKcUb5KFY7L9xiCA5tFbZW5Di5m8QLQKGxP
\r
31 qbtoM4IdDFqZyptcJTE5XxYZxWPvqMZdZ1H9mWovmgxFELdTmBJUwntmH4ufN4DkCMwH
\r
32 78G23doK5jWempK3Nup1LvGFbljDLAXKanhSnPvBcoPCJCnCYbKL0Z9XfmRuGHAoZSe6
\r
35 X-Received: by 10.13.218.71 with SMTP id c68mr17715709ywe.126.1433788897355;
\r
36 Mon, 08 Jun 2015 11:41:37 -0700 (PDT)
\r
37 Received: by 10.129.123.197 with HTTP; Mon, 8 Jun 2015 11:41:37 -0700 (PDT)
\r
38 In-Reply-To: <871thmivpt.fsf@maritornes.cs.unb.ca>
\r
40 <CACMMjMLecmXopb8AATjE3UuCnNLOO+5Nmev5X8K-UostDEUdrQ@mail.gmail.com>
\r
41 <871thmivpt.fsf@maritornes.cs.unb.ca>
\r
42 Date: Mon, 8 Jun 2015 20:41:37 +0200
\r
44 <CACMMjM+twCQ9MjB6H51eVW-izekpStNT5+u75LUu9rduG1CWEQ@mail.gmail.com>
\r
45 Subject: Re: BUG: maildir flags sync with database relative path results in
\r
47 From: Morgan Veyret <morgan.veyret@gmail.com>
\r
48 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
49 Content-Type: multipart/alternative; boundary=94eb2c081926e8ee74051805fde2
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.18
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Mon, 08 Jun 2015 18:41:42 -0000
\r
64 --94eb2c081926e8ee74051805fde2
\r
65 Content-Type: text/plain; charset=UTF-8
\r
67 It does the job, now opening the database with a relative path raise
\r
72 On Mon, Jun 8, 2015 at 8:02 AM, David Bremner <david@tethera.net> wrote:
\r
74 > Morgan Veyret <morgan.veyret@gmail.com> writes:
\r
77 > > As I understand it's expected that the database path should be absolute
\r
79 > > corrupting the database when the path is relative sounds dangerous.
\r
81 > Thanks for the report. I can see how this could happen, since the
\r
82 > internal functions _notmuch_message_add_file_name and
\r
83 > _notmuch_database_relative_path classify message filenames into absolute
\r
84 > paths starting with the database path and paths relative to the database
\r
87 > The obvious solution is to reject non-absolute paths in
\r
88 > notmuch_database_open_verbose. A slightly friendlier approach would be
\r
89 > to canonicalize the path, but this might have unforseen consequences for
\r
90 > clients relying on the database path being exactly what they pass in.
\r
92 > Can you see if the attached patch "fixes" it for you? You'll have to
\r
93 > rebuild notmuch from source. The patch should apply to 0.20 or later.
\r
96 > diff --git a/lib/database.cc b/lib/database.cc
\r
97 > index 78a24f7..2a5b82a 100644
\r
98 > --- a/lib/database.cc
\r
99 > +++ b/lib/database.cc
\r
100 > @@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,
\r
104 > + if (path[0] != '/') {
\r
105 > + message = strdup ("Error: Database path must be absolute.\n");
\r
106 > + status = NOTMUCH_STATUS_FILE_ERROR;
\r
110 > if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path,
\r
112 > message = strdup ("Out of memory\n");
\r
113 > status = NOTMUCH_STATUS_OUT_OF_MEMORY;
\r
117 --94eb2c081926e8ee74051805fde2
\r
118 Content-Type: text/html; charset=UTF-8
\r
119 Content-Transfer-Encoding: quoted-printable
\r
121 <div dir=3D"ltr"><div>It does the job, now opening the database with a rela=
\r
122 tive path raise<br></div>a NotmuchError.<br><br><br></div><div class=3D"gma=
\r
123 il_extra"><br><div class=3D"gmail_quote">On Mon, Jun 8, 2015 at 8:02 AM, Da=
\r
124 vid Bremner <span dir=3D"ltr"><<a href=3D"mailto:david@tethera.net" targ=
\r
125 et=3D"_blank">david@tethera.net</a>></span> wrote:<br><blockquote class=
\r
126 =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
\r
127 ing-left:1ex"><span class=3D"">Morgan Veyret <<a href=3D"mailto:morgan.v=
\r
128 eyret@gmail.com">morgan.veyret@gmail.com</a>> writes:<br>
\r
131 > As I understand it's expected that the database path should be abs=
\r
133 > corrupting the database when the path is relative sounds dangerous.<br=
\r
136 </span>Thanks for the report.=C2=A0 I can see how this could happen, since =
\r
138 internal functions _notmuch_message_add_file_name and<br>
\r
139 _notmuch_database_relative_path classify message filenames into absolute<br=
\r
141 paths starting with the database path and paths relative to the database<br=
\r
145 The obvious solution is to reject non-absolute paths in<br>
\r
146 notmuch_database_open_verbose. A slightly friendlier approach would be<br>
\r
147 to canonicalize the path, but this might have unforseen consequences for<br=
\r
149 clients relying on the database path being exactly what they pass in.<br>
\r
151 Can you see if the attached patch "fixes" it for you? You'll =
\r
153 rebuild notmuch from source. The patch should apply to 0.20 or later.<br>
\r
155 <br>diff --git a/lib/database.cc b/lib/database.cc<br>
\r
156 index 78a24f7..2a5b82a 100644<br>
\r
157 --- a/lib/database.cc<br>
\r
158 +++ b/lib/database.cc<br>
\r
159 @@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,<br>
\r
160 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto DONE;<br>
\r
161 =C2=A0 =C2=A0 =C2=A0}<br>
\r
163 +=C2=A0 =C2=A0 if (path[0] !=3D '/') {<br>
\r
164 +=C2=A0 =C2=A0 =C2=A0 =C2=A0message =3D strdup ("Error: Database path =
\r
165 must be absolute.\n");<br>
\r
166 +=C2=A0 =C2=A0 =C2=A0 =C2=A0status =3D NOTMUCH_STATUS_FILE_ERROR;<br>
\r
167 +=C2=A0 =C2=A0 =C2=A0 =C2=A0goto DONE;<br>
\r
168 +=C2=A0 =C2=A0 }<br>
\r
170 =C2=A0 =C2=A0 =C2=A0if (! (notmuch_path =3D talloc_asprintf (local, "%=
\r
171 s/%s", path, ".notmuch"))) {<br>
\r
172 =C2=A0 =C2=A0 =C2=A0 =C2=A0 message =3D strdup ("Out of memory\n"=
\r
174 =C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D NOTMUCH_STATUS_OUT_OF_MEMORY;<br>
\r
175 <br></blockquote></div><br></div>
\r
177 --94eb2c081926e8ee74051805fde2--
\r