Re: [PATCH v4 09/16] index encrypted parts when asked.
[notmuch-archives.git] / 2e / 0238e609a9bb8defa8ddd587214fdd823ed9b4
1 Return-Path: <jani@nikula.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 arlo.cworth.org (Postfix) with ESMTP id 79A806DE0008\r
6  for <notmuch@notmuchmail.org>; Sun, 10 Apr 2016 12:44:48 -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.558\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.558 tagged_above=-999 required=5 tests=[AWL=0.162,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
13  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id nfu7wjkc7SG1 for <notmuch@notmuchmail.org>;\r
17  Sun, 10 Apr 2016 12:44:40 -0700 (PDT)\r
18 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
19  [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 427156DE028C for\r
20  <notmuch@notmuchmail.org>; Sun, 10 Apr 2016 12:44:40 -0700 (PDT)\r
21 Received: by mail-wm0-f66.google.com with SMTP id n3so16822443wmn.1\r
22  for <notmuch@notmuchmail.org>; Sun, 10 Apr 2016 12:44:40 -0700 (PDT)\r
23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
24  d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
25  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
26  bh=JyHaoTek1t3VbWiG4zUshy1t8BT/SLk37xZ1+bmvAqs=;\r
27  b=m7pApQwS3msxZIQGqIAUDfUJ/5jNHKGscj71SZke6stmbvvQtD1GfBFrHaZ/frYyv0\r
28  xbYsef75gDTEd7IqeoNidHR8I7ghxCZDyZ0sSnRDR/rk3utaybJ7UtZKcifJa/cGldFg\r
29  MMt9osFZ534keakij//bbQZ/G0RJuTXYKYHPsoX2+KhEUJwXLTiZvSBrVRlN2inhGt+e\r
30  Kg54o+EEXJkCMInmU7iOdc0W69DY4uxXMl3XFQK1X5z6aM9uvNu944Ru7Nh1GkkHUghy\r
31  moUGdwAg3ibLrXwzU1xW3Fq5e46pktwtouqM13aN+qL6pN/PF4IzwYqb907CRjLFzRDU\r
32  8A2w==\r
33 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
34  d=1e100.net; s=20130820;\r
35  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
36  :references;\r
37  bh=JyHaoTek1t3VbWiG4zUshy1t8BT/SLk37xZ1+bmvAqs=;\r
38  b=lh0LzcHVho/8kjJSxPimgilGQgRLf8LDZZu1oYE0xPEguiDPwI7fCHYM816ukkdFjU\r
39  CDW7yiPwY0gefaierS/J7utSAccBlyZWR/pfvFIJOqXznYOzaUfPyEq3seclrgV7BSm2\r
40  Zqf11BzEPOA7vhW6nTAG64uNGjSuw1aYx7AB/Ldu8dr8gHx7plG5G2X2G+e9Vx8yStlY\r
41  iMbnmv0SJ0snaloq6B8fssx/BUj4HeI5ehnZWLvPwiVugQpL/T6k16gOL8FFVgTKMQik\r
42  CqTgvLK6K3Kol4KTu5GZcFakS9mrGJsIn8DZQIc5EjJLuY+jmsn3u2G0bnTJcTch2PbL\r
43  Pjbw==\r
44 X-Gm-Message-State:\r
45  AD7BkJK8MZp0W8W6QEBoxQTqAHFGxcPEiijqiK9tUmBQZc7k+WDkIQ8U7XqvGHzrCgqCzg==\r
46 X-Received: by 10.28.176.133 with SMTP id z127mr14940871wme.66.1460317479006; \r
47  Sun, 10 Apr 2016 12:44:39 -0700 (PDT)\r
48 Received: from localhost (mobile-access-bcee7f-102.dhcp.inet.fi.\r
49  [188.238.127.102])\r
50  by smtp.gmail.com with ESMTPSA id m134sm13720530wmd.14.2016.04.10.12.44.38\r
51  (version=TLSv1/SSLv3 cipher=OTHER);\r
52  Sun, 10 Apr 2016 12:44:38 -0700 (PDT)\r
53 From: Jani Nikula <jani@nikula.org>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH 2/3] lib: fix handling of one character long directory names\r
56  at top level\r
57 Date: Sun, 10 Apr 2016 22:43:22 +0300\r
58 Message-Id: <1460317403-13714-2-git-send-email-jani@nikula.org>\r
59 X-Mailer: git-send-email 2.1.4\r
60 In-Reply-To: <1460317403-13714-1-git-send-email-jani@nikula.org>\r
61 References: <1460317403-13714-1-git-send-email-jani@nikula.org>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.20\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Sun, 10 Apr 2016 19:44:48 -0000\r
75 \r
76 The code to skip multiple slashes in _notmuch_database_split_path()\r
77 skips back one character too much. This is compensated by a +1 in the\r
78 length parameter to the strndup() call. Mostly this works fine, but if\r
79 the path is to a file under a top level directory with one character\r
80 long name, the directory part is mistaken to be part of the file name\r
81 (slash == path in code). The returned directory name will be the empty\r
82 string and the basename will be the full path, breaking the indexing\r
83 logic in notmuch new.\r
84 \r
85 Fix the multiple slash skipping to keep the slash variable pointing at\r
86 the last slash, and adjust strndup() accordingly.\r
87 \r
88 The bug was introduced in\r
89 \r
90 commit e890b0cf4011fd9fd77ebd87343379e4a778888b\r
91 Author: Carl Worth <cworth@cworth.org>\r
92 Date:   Sat Dec 19 13:20:26 2009 -0800\r
93 \r
94     database: Store the parent ID for each directory document.\r
95 \r
96 just a little over two months after the initial commit in the Notmuch\r
97 code history, making this the longest living bug in Notmuch to date.\r
98 ---\r
99  lib/database.cc  | 4 ++--\r
100  test/T050-new.sh | 5 -----\r
101  2 files changed, 2 insertions(+), 7 deletions(-)\r
102 \r
103 diff --git a/lib/database.cc b/lib/database.cc\r
104 index 3b342f136a53..b8486f7d5271 100644\r
105 --- a/lib/database.cc\r
106 +++ b/lib/database.cc\r
107 @@ -1781,7 +1781,7 @@ _notmuch_database_split_path (void *ctx,\r
108  \r
109      /* Finally, skip multiple slashes. */\r
110      while (slash != path) {\r
111 -       if (*slash != '/')\r
112 +       if (*(slash - 1) != '/')\r
113             break;\r
114  \r
115         --slash;\r
116 @@ -1794,7 +1794,7 @@ _notmuch_database_split_path (void *ctx,\r
117             *basename = path;\r
118      } else {\r
119         if (directory)\r
120 -           *directory = talloc_strndup (ctx, path, slash - path + 1);\r
121 +           *directory = talloc_strndup (ctx, path, slash - path);\r
122      }\r
123  \r
124      return NOTMUCH_STATUS_SUCCESS;\r
125 diff --git a/test/T050-new.sh b/test/T050-new.sh\r
126 index 174715aa2781..53e02d22c383 100755\r
127 --- a/test/T050-new.sh\r
128 +++ b/test/T050-new.sh\r
129 @@ -170,7 +170,6 @@ test_expect_equal "$output" "(D) add_files, pass 3: queuing leftover directory $\r
130  No new mail. Removed 3 messages."\r
131  \r
132  test_begin_subtest "One character directory at top level"\r
133 -test_subtest_known_broken\r
134  \r
135  generate_message [dir]=A\r
136  generate_message [dir]=A/B\r
137 @@ -179,10 +178,6 @@ generate_message [dir]=A/B/C\r
138  output=$(NOTMUCH_NEW --debug)\r
139  test_expect_equal "$output" "Added 3 new messages to the database."\r
140  \r
141 -# clean up after the broken test to not mess up other tests\r
142 -rm -rf "${MAIL_DIR}"/A\r
143 -NOTMUCH_NEW 2>&1 > /dev/null\r
144 -\r
145  test_begin_subtest "Support single-message mbox"\r
146  cat > "${MAIL_DIR}"/mbox_file1 <<EOF\r
147  From test_suite@notmuchmail.org Fri Jan  5 15:43:57 2001\r
148 -- \r
149 2.1.4\r
150 \r