[PATCH] notmuch-new.c infinite recursion symlink bug
Austin Clements
amdragon at mit.edu
Tue Jun 21 09:01:17 PDT 2011
On Tue, Jun 21, 2011 at 8:42 AM, Daniel Kahn Gillmor
<dkg at fifthhorseman.net> wrote:
> My point is: there are lots of ways to get infinite recursions via
> symlinks; hard-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.
More information about the notmuch
mailing list