Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I avoid traversing into an endlessly recursive directory link?
    text
    copied!<p>I have some functionality that traverses the filesystem recursively using <code>FindFirstFile()</code> and <code>FindNextFile()</code>. This works fine, but the problem is that on occasion it comes across some kind of recursive link. For example, <code>C:\foo\bar</code> links to <code>C:\foo</code>. Most of these links are implemented with reparse points, so it is enough to avoid traversing into a folder with the <code>FILE_FLAG_REPARSE_POINT</code> attribute set. However, on rare occasions one of these links will NOT have that flag set and thus the code gets stuck in an endless loop until the stack is exhausted.</p> <p>My question is how can I detect these links in order to avoid endlessly traversing into them?</p> <p>Unfortunately I do not have access to an environment that reproduces the problem so I can't gather any more information; all I have to go on are some crash dumps from Windows Error Reporting. I have seen these non-reparse links on local (NTFS) filesystems, and possibly also on remote (SMB) file systems but I'm not 100% on that.</p> <p><strong>EDIT</strong>: More details from one of the dumps.</p> <p>In one case the problem folder is <code>C:\users\Administrator\AppData\Local\Application Data</code>. Here the <code>Application Data</code> part repeats over 700 times, and the total length of the path is 12K characters (24k bytes). Due to local variables the stack is exhausted well before the 32K limit is reached. This is a Windows 7 machine and the filesystem is NTFS, so normally <code>Application Data</code> is a junction to <code>AppData\Local</code>. However, my code is not detecting this particular folder as a junction. In the logs I can see it is detecting other junctions, so this leads me to believe it is an environmental issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload