mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) a15f7dd1fb
: [Backport #15803]
Always mark the string returned by File.realpath as tainted This string can include elements that were not in either string passed to File.realpath, even if one of the strings is an absolute path, due to symlinks: ```ruby Dir.mkdir('b') unless File.directory?('b') File.write('b/a', '') unless File.file?('b/a') File.symlink('b', 'c') unless File.symlink?('c') path = File.realpath('c/a'.untaint, Dir.pwd.untaint) path # "/home/testr/ruby/b/a" path.tainted? # should be true, as 'b' comes from file system ``` [Bug #15803] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
662a3ca806
commit
920b6e156d
3 changed files with 3 additions and 3 deletions
2
file.c
2
file.c
|
@ -4145,7 +4145,7 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, enum rb_realpath_mode mode
|
|||
}
|
||||
}
|
||||
|
||||
OBJ_INFECT(resolved, unresolved_path);
|
||||
rb_obj_taint(resolved);
|
||||
RB_GC_GUARD(unresolved_path);
|
||||
RB_GC_GUARD(curdir);
|
||||
return resolved;
|
||||
|
|
|
@ -298,7 +298,7 @@ class TestFile < Test::Unit::TestCase
|
|||
assert_predicate(File.realpath(base, dir), :tainted?)
|
||||
base.untaint
|
||||
dir.untaint
|
||||
assert_not_predicate(File.realpath(base, dir), :tainted?)
|
||||
assert_predicate(File.realpath(base, dir), :tainted?)
|
||||
assert_predicate(Dir.chdir(dir) {File.realpath(base)}, :tainted?)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.5.6"
|
||||
#define RUBY_RELEASE_DATE "2019-08-26"
|
||||
#define RUBY_PATCHLEVEL 174
|
||||
#define RUBY_PATCHLEVEL 175
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2019
|
||||
#define RUBY_RELEASE_MONTH 8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue