1 Return-Path: <taylor@codecafe.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 olra.theworths.org (Postfix) with ESMTP id CC0CA431FD0
\r
6 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:50:32 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 BwanKUUnpuqp for <notmuch@notmuchmail.org>;
\r
16 Fri, 10 Jun 2011 00:50:32 -0700 (PDT)
\r
17 Received: from mail-gx0-f181.google.com (mail-gx0-f181.google.com
\r
18 [209.85.161.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 1CD83431FB6
\r
21 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:50:32 -0700 (PDT)
\r
22 Received: by gxk9 with SMTP id 9so1855307gxk.26
\r
23 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:50:31 -0700 (PDT)
\r
24 Received: by 10.236.186.106 with SMTP id v70mr2014013yhm.408.1307692231410;
\r
25 Fri, 10 Jun 2011 00:50:31 -0700 (PDT)
\r
26 Received: from localhost (cpe-70-113-59-5.austin.res.rr.com [70.113.59.5])
\r
27 by mx.google.com with ESMTPS id o47sm1196854yhn.16.2011.06.10.00.50.29
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Fri, 10 Jun 2011 00:50:30 -0700 (PDT)
\r
30 Date: Fri, 10 Jun 2011 02:50:27 -0500
\r
31 From: Taylor Carpenter <taylor@codecafe.com>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH] notmuch-new.c infinite recursion symlink bug
\r
34 Message-ID: <20110610075027.GA75006@codecafe.com>
\r
35 References: <20110610073208.GA74787@codecafe.com>
\r
37 Content-Type: text/plain; charset=us-ascii
\r
38 Content-Disposition: inline
\r
39 In-Reply-To: <20110610073208.GA74787@codecafe.com>
\r
40 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
41 X-Mailman-Approved-At: Mon, 20 Jun 2011 15:19:13 -0700
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Fri, 10 Jun 2011 07:50:32 -0000
\r
56 On 06/10/11 at 02:32P, Taylor Carpenter wrote:
\r
57 > If a symlink points to . then there will be an infinite recursion. The included patch fixes that.
\r
60 I did not realize this was needed in the count function as well. New
\r
61 patch included that does both.
\r
63 --- notmuch-new.c.orig 2011-06-10 00:03:09.000000000 -0500
\r
64 +++ notmuch-new.c 2011-06-10 02:46:18.000000000 -0500
\r
67 notmuch_bool_t is_maildir, new_directory;
\r
69 + char lpath[PATH_MAX], filepath[PATH_MAX];
\r
72 if (stat (path, &st)) {
\r
73 fprintf (stderr, "Error reading directory %s: %s\n",
\r
74 @@ -296,6 +298,14 @@
\r
76 /* XXX: Eventually we'll want more sophistication to let the
\r
77 * user specify files to be ignored. */
\r
79 + if (entry->d_type == DT_LNK) {
\r
80 + snprintf(filepath, sizeof(filepath), "%s/%s", path, entry->d_name);
\r
81 + if ((len = readlink(filepath, lpath, sizeof(lpath))) > 0)
\r
82 + if (strncmp(lpath, ".", len-1) == 0)
\r
86 if (strcmp (entry->d_name, ".") == 0 ||
\r
87 strcmp (entry->d_name, "..") == 0 ||
\r
88 (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r
90 struct dirent **fs_entries = NULL;
\r
91 int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);
\r
93 + char lpath[PATH_MAX], filepath[PATH_MAX];
\r
96 if (num_fs_entries == -1) {
\r
97 fprintf (stderr, "Warning: failed to open directory %s: %s\n",
\r
98 @@ -633,6 +645,13 @@
\r
100 /* XXX: Eventually we'll want more sophistication to let the
\r
101 * user specify files to be ignored. */
\r
102 + if (entry->d_type == DT_LNK) {
\r
103 + snprintf(filepath, sizeof(filepath), "%s/%s", path, entry->d_name);
\r
104 + if ((len = readlink(filepath, lpath, sizeof(lpath))) > 0)
\r
105 + if (strncmp(lpath, ".", len-1) == 0)
\r
109 if (strcmp (entry->d_name, ".") == 0 ||
\r
110 strcmp (entry->d_name, "..") == 0 ||
\r
111 strcmp (entry->d_name, ".notmuch") == 0)
\r