Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id CC399431FD0 for ; Tue, 21 Jun 2011 09:01:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cuya1VQ-rRCh for ; Tue, 21 Jun 2011 09:01:18 -0700 (PDT) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 4EF50431FB6 for ; Tue, 21 Jun 2011 09:01:18 -0700 (PDT) Received: by qyk9 with SMTP id 9so2045036qyk.5 for ; Tue, 21 Jun 2011 09:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=DEPv2cG8I+YymjPZ/Io4rESDFYFxU1w9gZCIcatLDp4=; b=hXpZuSPlqASJQZdeQXvb8whbPn+ce20EeYgEtQf3B52m00K3BM6cO7WKrXjGu7riwk s7sKz78Xo1pXjz1uSncTf+IKU63pcmOANIIxaFfsKTOe9+HiOxH5zThAm47x7zPxCPSW 3Gwwg42tcr8+JkORNjr4S2Jdmdwrdn8BPjVg4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=AyfDRys8ZmzsRqS3uDjo63JTzVM8nY7yCwjRyktdUD7JFW2LUScg4r0c5SJIcUxqK9 oE5bXqwzjZ6iYbRGb9ynfVv/NjyeGQfS5iFb9fxNtOYOlT/9NytO49y1LFKgNUvXGmH4 /bvGDTs/Q4o9UlEmTkq81xY9Y76V+y2zCj3hM= MIME-Version: 1.0 Received: by 10.229.18.67 with SMTP id v3mr5268842qca.100.1308672077488; Tue, 21 Jun 2011 09:01:17 -0700 (PDT) Sender: amdragon@gmail.com Received: by 10.229.32.197 with HTTP; Tue, 21 Jun 2011 09:01:17 -0700 (PDT) In-Reply-To: <4E0091AE.5070609@fifthhorseman.net> References: <20110610073208.GA74787@codecafe.com> <4E0091AE.5070609@fifthhorseman.net> Date: Tue, 21 Jun 2011 12:01:17 -0400 X-Google-Sender-Auth: s8hXmck4YsOkSc_igawn0-ls_c8 Message-ID: Subject: Re: [PATCH] notmuch-new.c infinite recursion symlink bug From: Austin Clements To: notmuch Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2011 16:01:18 -0000 On Tue, Jun 21, 2011 at 8:42 AM, Daniel Kahn Gillmor wrote: > My point is: there are lots of ways to get infinite recursions via > symlinks; =A0hard-coding a check for one specific way seems like a > sub-optimal approach, because it leaves the other paths still present, > and introduces an unexpected/surprising asymmetry. > > I'm not sure what the specific right way is to solve the problem you > identified, though. A simple solution to this problem would be to record the inode numbers of each visited directory, probably in a hash table in add_files_state_t. At the beginning of add_files_recursive, right after it stat's the directory, check if st.st_ino is in this hash table; if it is, return immediately, otherwise add it to the hash table and proceed as usual. Alternatively, because of folder search, it might be better to keep a stack of inode numbers to eliminate loops while retaining notmuch's current approach of repeatedly indexing mail that's symlinked in multiple folders.