Menu

#4 Patch for handling recursive symlink (bug 2146328)

open
nobody
None
5
2013-02-14
2013-02-14
Dennis Ju
No

Hello,

I encountered the bug 2146328 (https://sourceforge.net/tracker/?func=detail&aid=2146328&group_id=154048&atid=790218#) where recursive symlink cause an infinite recursion. To reproduce, you need to create a symlink that points back to its own directory (for example, symlink "a" in folder /test points to "/test/a"). This is perfectly legal and in Finder or Terminal, you can infinitely dig into the subfolders (/test/a/a/a/a/a/a/...).

I've created a quick patch that will skip over any recursive symlinks.

Discussion

  • Dennis Ju

    Dennis Ju - 2013-02-14
     
  • Matthew Donoughe

    What if you have /test/a/b/b/b/b/b/b/b/b/b instead? This patch looks like it only handles if the link points at the root directory. It'd be better to keep a stack of inodes seen this scan and only process inodes that are not on the stack(not a parent of the subdirectory being considered).

     
  • Dennis Ju

    Dennis Ju - 2013-03-07

    Good catch. You can still get caught in a loop like /test/a/test/a/test/...

    I'll try a better fix when I get the chance. For the time being, I'm going to ignore symlinks altogether as I don't need it for my application.

     
  • Matthew Donoughe

    We do have code in there for working with inodes so it shouldn't be too difficult.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.