[issue13734] Add a generic directory walker method to avoid symlink attacks

Antoine Pitrou report at bugs.python.org
Tue Jan 31 22:56:14 CET 2012


Antoine Pitrou <pitrou at free.fr> added the comment:

> I was a little worried about the performance impact, so I did some
> trivial benchmarks:
> - O(depth) fwalk() is actually a tiny bit faster than walk() (it may
> be because we don't do as much path lookup)
> - O(1) fwalk() is around 20% slower, on a pure-traversal benchmark (so
> in a realistic use case where we would actually do something with the
> values returned by fwalk() the difference shouldn't be that
> noticeable)

I think the O(depth) version is fine. The O(1) version is quite more
complicated, difficult to follow, and it seems less robust (it doesn't
use try/finally and therefore might leak fds if the generator isn't
exhausted before being destroyed).

On modern systems you have at least 1024 fds, so the restriction
shouldn't be a problem.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13734>
_______________________________________


More information about the Python-bugs-list mailing list