Skip to content

Commit f3f850e

Browse files
nobuhsbt
authored andcommitted
Fix exception namespace
* lib/fileutils.rb (remove_entry_secure): EISDIR is under the Errno namespace. [ruby-core:91362] [Bug #15577] From: Tietew (Toru Iwase) <tietew@tietew.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 5814e3b commit f3f850e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/fileutils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def remove_entry_secure(path, force = false)
697697
f.chown euid, -1
698698
f.chmod 0700
699699
}
700-
rescue EISDIR # JRuby in non-native mode can't open files as dirs
700+
rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
701701
File.lstat(dot_file).tap {|fstat|
702702
unless fu_stat_identical_entry?(st, fstat)
703703
# symlink (TOC-to-TOU attack?)

test/fileutils/test_fileutils.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,15 @@ def test_remove_entry_secure
740740
remove_entry_secure 'tmp/tmpdir/c', true
741741
assert_file_not_exist 'tmp/tmpdir/a'
742742
assert_file_not_exist 'tmp/tmpdir/c'
743+
744+
File.chmod(01777, 'tmp/tmpdir')
745+
Dir.mkdir 'tmp/tmpdir/d', 0
746+
assert_raise(Errno::EACCES) {remove_entry_secure 'tmp/tmpdir/d'}
747+
File.chmod 0777, 'tmp/tmpdir/d'
748+
Dir.rmdir 'tmp/tmpdir/d'
749+
743750
Dir.rmdir 'tmp/tmpdir'
751+
744752
end
745753

746754
def test_remove_entry_secure_symlink

0 commit comments

Comments
 (0)