Re: [PATCH] lib: reword comment about XFOLDER: prefix
[notmuch-archives.git] / 78 / 14502f303ea87bcc46822f89ec2b15047ab091
1 Return-Path: <david@tethera.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 arlo.cworth.org (Postfix) with ESMTP id 7E2FA6DE1502\r
6  for <notmuch@notmuchmail.org>; Sun,  7 Jun 2015 23:04:11 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.208\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.208 tagged_above=-999 required=5 tests=[AWL=0.208]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id lBgrY67LLRfp for <notmuch@notmuchmail.org>;\r
16  Sun,  7 Jun 2015 23:04:09 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 387866DE119C\r
20  for <notmuch@notmuchmail.org>; Sun,  7 Jun 2015 23:04:08 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <david@tethera.net>)\r
23  id 1Z1q8v-0007Nv-5D; Mon, 08 Jun 2015 06:02:41 +0000\r
24 Received: (nullmailer pid 29648 invoked by uid 1000); Mon, 08 Jun 2015\r
25  06:02:22 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: Morgan Veyret <morgan.veyret@gmail.com>, notmuch@notmuchmail.org\r
28 Subject: Re: BUG: maildir flags sync with database relative path results in\r
29  corrupted filename\r
30 In-Reply-To:\r
31  <CACMMjMLecmXopb8AATjE3UuCnNLOO+5Nmev5X8K-UostDEUdrQ@mail.gmail.com>\r
32 References:\r
33  <CACMMjMLecmXopb8AATjE3UuCnNLOO+5Nmev5X8K-UostDEUdrQ@mail.gmail.com>\r
34 User-Agent: Notmuch/0.20+15~ga1b054b (http://notmuchmail.org) Emacs/24.4.1\r
35  (x86_64-pc-linux-gnu)\r
36 Date: Mon, 08 Jun 2015 08:02:22 +0200\r
37 Message-ID: <871thmivpt.fsf@maritornes.cs.unb.ca>\r
38 MIME-Version: 1.0\r
39 Content-Type: multipart/mixed; boundary="=-=-="\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.18\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44  <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Mon, 08 Jun 2015 06:04:11 -0000\r
53 \r
54 --=-=-=\r
55 Content-Type: text/plain\r
56 \r
57 Morgan Veyret <morgan.veyret@gmail.com> writes:\r
58 \r
59 >\r
60 > As I understand it's expected that the database path should be absolute but\r
61 > corrupting the database when the path is relative sounds dangerous.\r
62 \r
63 Thanks for the report.  I can see how this could happen, since the\r
64 internal functions _notmuch_message_add_file_name and\r
65 _notmuch_database_relative_path classify message filenames into absolute\r
66 paths starting with the database path and paths relative to the database\r
67 root.\r
68 \r
69 The obvious solution is to reject non-absolute paths in\r
70 notmuch_database_open_verbose. A slightly friendlier approach would be\r
71 to canonicalize the path, but this might have unforseen consequences for\r
72 clients relying on the database path being exactly what they pass in.\r
73 \r
74 Can you see if the attached patch "fixes" it for you? You'll have to\r
75 rebuild notmuch from source. The patch should apply to 0.20 or later.\r
76 \r
77 \r
78 --=-=-=\r
79 Content-Type: text/x-diff\r
80 Content-Disposition: inline; filename=test.diff\r
81 \r
82 diff --git a/lib/database.cc b/lib/database.cc\r
83 index 78a24f7..2a5b82a 100644\r
84 --- a/lib/database.cc\r
85 +++ b/lib/database.cc\r
86 @@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,\r
87         goto DONE;\r
88      }\r
89  \r
90 +    if (path[0] != '/') {\r
91 +       message = strdup ("Error: Database path must be absolute.\n");\r
92 +       status = NOTMUCH_STATUS_FILE_ERROR;\r
93 +       goto DONE;\r
94 +    }\r
95 +\r
96      if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {\r
97         message = strdup ("Out of memory\n");\r
98         status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
99 \r
100 --=-=-=--\r