Comments (4)
Appears to have been introduced by 025d72a (defend iterator against symlink attack). Possibly the following patch implements what was intended correctly:
diff --git a/lib/Path/Tiny.pm b/lib/Path/Tiny.pm
index 6ae2e32..85d8633 100644
--- a/lib/Path/Tiny.pm
+++ b/lib/Path/Tiny.pm
@@ -512,7 +512,7 @@ sub iterator {
opendir( $dh, $current->[PATH] )
or _throw( 'opendir', [$dh, $current->[PATH]] );
$dirs[0] = $dh;
- if ( -l $dirs[0] && ! $args->{follow_symlinks} ) {
+ if ( -l $current->[PATH] && ! $args->{follow_symlinks} ) {
# Symlink attack! It was a real dir, but is now a symlink!
# N.B. we check *after* opendir so we don't have a race
shift @dirs and next;
from path-tiny.
Thanks for the bug report. I didn't see anything in the docs that
suggested it wouldn't work (and I didn't get any warnings in testing, which
is odd).
Your "fix" might be the best alternative. There is still a race condition
in there, but harder to attack, since it would require someone to swap a
symlink for a dir (before the opendir) and then swap it back (before the
path check).
And if there's no way for the OS to know if an open handle came from a
symlink at all, then the point is moot, I guess.
David
David Golden [email protected]
Take back your inbox! → http://www.bunchmail.com/
Twitter/IRC: @xdg
from path-tiny.
Strange. That warning disappeared in 5.16.
I've fixed it per your suggestion and shipped 0.019.
from path-tiny.
Thanks for the quick response.
from path-tiny.
Related Issues (20)
- RFC: `with( $callback )` method HOT 1
- Tests fail on Windows 11: Failed test 'lstat' ... Error resolving realpath HOT 2
- mkdir fails if the directory exists HOT 1
- Broken tilde expansion for home directories of accounts with special characters HOT 1
- Windows 11: Failed test 'lstat' at t\filesystem.t line 420 (lstat->size returns zero) HOT 1
- Windows 11: Failed test 'relative symlinks with updir' at t/symlinks.t line 31. HOT 1
- Windows 11: Failed test 'Follow symlinks' at t/recurse.t line 139 HOT 1
- t/basic.t fails with ~root = / HOT 9
- Windows 11: Failed test "relative on absolute paths with symlinks" in t/rel-abs.t
- Feature request: $path->children('*.txt') or $path->glob('*.txt')
- A File::Temp object is created as an opened file, but the cached_temp is not open HOT 1
- Feature request: slurp_* support for chomp argument
- RFE: copy() & move() on existing Path::Tiny file object: return existing object
- Windows 11 fails test t/basic.t
- Feature Request: limit path->lines result to those matching pattern HOT 2
- Feature Request: integrate functionality of File::pushd
- Add is_temp, is_tempfile and is_tempdir predicates
- Support size option for digest to limit to first n bytes HOT 1
- Misleading error message for spew in non-existent dir HOT 10
- Adding 'dot' child
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path-tiny.