summaryrefslogtreecommitdiff
path: root/test/irb
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-24 11:00:10 +0000
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-24 11:00:10 +0000
commit6d14c47c20455828b7945a15920a18c4eee13d42 (patch)
treeb4b4f63c63523034ceaafc67c4bbf33c3f01a6bf /test/irb
parentdff3d5dc6943ff7f72882bb3f3349737d7b8e3a8 (diff)
Fix TOCTTOU and avoid to read existing unreadable file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_workspace.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb
index ce4c86d20b..970dc7fd14 100644
--- a/test/irb/test_workspace.rb
+++ b/test/irb/test_workspace.rb
@@ -32,6 +32,19 @@ module TestIRB
end
end
+ def test_code_around_binding_with_existing_unreadable_file
+ Tempfile.create do |f|
+ code = "IRB::WorkSpace.new(binding)\n"
+ f.print(code)
+ f.close
+
+ File.chmod(0, f.path)
+
+ workspace = eval(code, binding, f.path)
+ assert_equal(nil, workspace.code_around_binding)
+ end
+ end
+
def test_code_around_binding_with_script_lines__
with_script_lines do |script_lines|
Tempfile.create do |f|