1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

adhoc patch for [druby-ja:123]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
seki 2005-04-11 14:48:50 +00:00
parent 9d7f33e08b
commit 3fe8250545
3 changed files with 35 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Mon Apr 11 23:47:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.r: [druby-ja:123] fix: When reference of my object is
loaded, the object is tainted.
* test/drb/test_drb.rb: ditto.
Mon Apr 11 22:18:23 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* dir.c, file.c (lstat): avoid warnings for mingw.

View file

@ -575,10 +575,19 @@ module DRb
end
raise(DRbConnError, 'connection closed') if str.nil?
raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
begin
Marshal::load(str)
rescue NameError, ArgumentError
DRbUnknown.new($!, str)
Thread.exclusive do
begin
save = Thread.current[:drb_untaint]
Thread.current[:drb_untaint] = []
Marshal::load(str)
rescue NameError, ArgumentError
DRbUnknown.new($!, str)
ensure
Thread.current[:drb_untaint].each do |x|
x.untaint
end
Thread.current[:drb_untaint] = save
end
end
end
@ -988,8 +997,13 @@ module DRb
# created to act as a stub for the remote referenced object.
def self._load(s)
uri, ref = Marshal.load(s)
if DRb.here?(uri)
return DRb.to_obj(ref)
obj = DRb.to_obj(ref)
if ((! obj.tainted?) && Thread.current[:drb_untaint])
Thread.current[:drb_untaint].push(obj)
end
return obj
end
self.new_with(uri, ref)

View file

@ -102,6 +102,15 @@ class TestDRbYield < Test::Unit::TestCase
@there.xarray_each {|x| assert_kind_of(XArray, x)}
@there.xarray_each {|*x| assert_kind_of(XArray, x[0])}
end
def test_06_taint
x = proc {}
assert(! x.tainted?)
@there.echo_yield(x) {|o|
assert_equal(x, o)
assert(! x.tainted?)
}
end
end
class TestRubyYield < TestDRbYield