diff options
author | kazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-24 11:00:10 +0000 |
---|---|---|
committer | kazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-24 11:00:10 +0000 |
commit | 6d14c47c20455828b7945a15920a18c4eee13d42 (patch) | |
tree | b4b4f63c63523034ceaafc67c4bbf33c3f01a6bf /lib/irb | |
parent | dff3d5dc6943ff7f72882bb3f3349737d7b8e3a8 (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 'lib/irb')
-rw-r--r-- | lib/irb/workspace.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index aa28db5502..9ce84b60fa 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -111,8 +111,11 @@ EOF file, pos = @binding.eval('[__FILE__, __LINE__]') unless defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file] - return unless File.exist?(file) - lines = File.readlines(file) + begin + lines = File.readlines(file) + rescue SystemCallError + return + end end pos -= 1 |