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 54D25431FD0
\r
6 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:32:15 -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 QgDLvsUPh+Sx for <notmuch@notmuchmail.org>;
\r
16 Fri, 10 Jun 2011 00:32:13 -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 1BE1D431FB6
\r
21 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:32:13 -0700 (PDT)
\r
22 Received: by gxk9 with SMTP id 9so1839695gxk.26
\r
23 for <notmuch@notmuchmail.org>; Fri, 10 Jun 2011 00:32:12 -0700 (PDT)
\r
24 Received: by 10.101.139.38 with SMTP id r38mr1522449ann.109.1307691132269;
\r
25 Fri, 10 Jun 2011 00:32:12 -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 x33sm2340635ana.48.2011.06.10.00.32.10
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Fri, 10 Jun 2011 00:32:11 -0700 (PDT)
\r
30 Date: Fri, 10 Jun 2011 02:32:08 -0500
\r
31 From: Taylor Carpenter <taylor@codecafe.com>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH] notmuch-new.c infinite recursion symlink bug
\r
34 Message-ID: <20110610073208.GA74787@codecafe.com>
\r
36 Content-Type: text/plain; charset=us-ascii
\r
37 Content-Disposition: inline
\r
38 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
39 X-Mailman-Approved-At: Mon, 20 Jun 2011 15:19:13 -0700
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\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: Fri, 10 Jun 2011 07:32:15 -0000
\r
54 If a symlink points to . then there will be an infinite recursion. The included patch fixes that.
\r
57 --- notmuch-new.c.orig 2011-06-10 00:03:09.000000000 -0500
\r
58 +++ notmuch-new.c 2011-06-10 02:10:37.000000000 -0500
\r
61 notmuch_bool_t is_maildir, new_directory;
\r
63 + char lpath[PATH_MAX], filepath[PATH_MAX];
\r
66 if (stat (path, &st)) {
\r
67 fprintf (stderr, "Error reading directory %s: %s\n",
\r
68 @@ -296,6 +298,14 @@
\r
70 /* XXX: Eventually we'll want more sophistication to let the
\r
71 * user specify files to be ignored. */
\r
73 + if (entry->d_type == DT_LNK) {
\r
74 + snprintf(filepath, sizeof(filepath), "%s/%s", path, entry->d_name);
\r
75 + if ((len = readlink(filepath, lpath, sizeof(lpath))) > 0)
\r
76 + if (strncmp(lpath, ".", len-1) == 0)
\r
80 if (strcmp (entry->d_name, ".") == 0 ||
\r
81 strcmp (entry->d_name, "..") == 0 ||
\r
82 (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r