diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 01:51:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 01:51:57 +0000 |
commit | 42727ceb195fc00cd25c0203cad518659c466342 (patch) | |
tree | 62e9c5a384502659bb7b17b00da25a7f096de67f /test/ruby/test_file.rb | |
parent | f5f6232399b1e4bf6b702b51bef4d9e36b42df1b (diff) | |
download | ruby-42727ceb195fc00cd25c0203cad518659c466342.tar.gz |
file.c: infect from arguments
* file.c (rb_check_realpath_internal): infetct the result with
arguments, no taint if none are tainted and cwd is not used.
[ruby-core:83583] [Bug #14060]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r-- | test/ruby/test_file.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 4be4e86131..e352d8fad9 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -283,6 +283,23 @@ class TestFile < Test::Unit::TestCase } end + def test_realpath_taintedness + Dir.mktmpdir('rubytest-realpath') {|tmpdir| + realdir = File.realpath(tmpdir) + assert_predicate(realdir, :tainted?) + dir, base = File.split(realdir) + assert_predicate(File.realpath(base, dir), :tainted?) + base.untaint + assert_predicate(File.realpath(base, dir), :tainted?) + base.taint + dir.untaint + assert_predicate(File.realpath(base, dir), :tainted?) + base.untaint + assert_not_predicate(File.realpath(base, dir), :tainted?) + assert_predicate(Dir.chdir(dir) {File.realpath(base)}, :tainted?) + } + end + def test_realdirpath Dir.mktmpdir('rubytest-realdirpath') {|tmpdir| realdir = File.realpath(tmpdir) |