summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 09:26:04 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 09:26:04 +0000
commit8db32a2b89df4687018fb0d7741acd284084e136 (patch)
treeeed022ce500909bdf39b563decbb38ab834636f9 /test
parent93081375feeebace137266f36f4c2c43aa2223e1 (diff)
dir.c: check NUL bytes
* dir.c (GlobPathValue): should be used in rb_push_glob only. other methods should use FilePathValue. https://hackerone.com/reports/302338 * dir.c (rb_push_glob): expand GlobPathValue From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_dir.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index cead4beb93..000bc24e85 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -156,6 +156,9 @@ class TestDir < Test::Unit::TestCase
open(File.join(@root, "}}a"), "wb") {}
assert_equal(%w(}}{} }}a).map {|f| File.join(@root, f)}, Dir.glob(File.join(@root, '}}{\{\},a}')))
assert_equal(%w(}}{} }}a b c).map {|f| File.join(@root, f)}, Dir.glob(File.join(@root, '{\}\}{\{\},a},b,c}')))
+ assert_raise(ArgumentError) {
+ Dir.glob([[@root, File.join(@root, "*")].join("\0")])
+ }
end
def test_glob_recursive
@@ -229,18 +232,23 @@ class TestDir < Test::Unit::TestCase
def test_entries
assert_entries(Dir.open(@root) {|dir| dir.entries})
assert_entries(Dir.entries(@root).to_a)
+ assert_raise(ArgumentError) {Dir.entries(@root+"\0")}
end
def test_foreach
+ assert_entries(Dir.open(@root) {|dir| dir.each.to_a})
assert_entries(Dir.foreach(@root).to_a)
+ assert_raise(ArgumentError) {Dir.foreach(@root+"\0").to_a}
end
def test_children
assert_entries(Dir.children(@root), true)
+ assert_raise(ArgumentError) {Dir.children(@root+"\0")}
end
def test_each_child
assert_entries(Dir.each_child(@root).to_a, true)
+ assert_raise(ArgumentError) {Dir.each_child(@root+"\0").to_a}
end
def test_dir_enc
@@ -397,6 +405,7 @@ class TestDir < Test::Unit::TestCase
end
assert_raise(Errno::ENOENT) {Dir.empty?(@nodir)}
assert_not_send([Dir, :empty?, File.join(@root, "b")])
+ assert_raise(ArgumentError) {Dir.empty?(@root+"\0")}
end
def test_glob_gc_for_fd