aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 02:22:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 02:22:10 +0000
commit83d20126648e4f6b99fa10e2d781ebde8d2b3c73 (patch)
tree75245f1d9da0a375a34f4f75da3a2705bc74307f /test
parent26c75b76311b34ad68aac76ce7fb94032cfd6869 (diff)
downloadruby-83d20126648e4f6b99fa10e2d781ebde8d2b3c73.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@60599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_file.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 4be4e86131..9d29bbbb65 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -283,6 +283,26 @@ class TestFile < Test::Unit::TestCase
}
end
+ def test_realpath_taintedness
+ Dir.mktmpdir('rubytest-realpath') {|tmpdir|
+ dir = File.realpath(tmpdir).untaint
+ File.write(File.join(dir, base = "test.file"), '')
+ base.taint
+ dir.taint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.untaint
+ dir.taint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.taint
+ dir.untaint
+ assert_predicate(File.realpath(base, dir), :tainted?)
+ base.untaint
+ dir.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)