summaryrefslogtreecommitdiff
path: root/test/ruby/test_rand.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:36:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:36:54 +0000
commit0b0dea752c0ef35d1a964b812a1a7fd033ab9e2e (patch)
tree5809b3a6a5fe233e25fccfd532f447c82fd67e8a /test/ruby/test_rand.rb
parent77898c33e38be4333112986f9f4f68867f8ce7ca (diff)
random.c: check initialize and load
* random.c (random_init, random_load): cannot initialize frozen object again, nor with tainted/untrusted object. [Bug #6540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rand.rb')
-rw-r--r--test/ruby/test_rand.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb
index c7139818de..a722c67f4a 100644
--- a/test/ruby/test_rand.rb
+++ b/test/ruby/test_rand.rb
@@ -484,4 +484,25 @@ END
Random.new.marshal_load(0)
}
end
+
+ def test_marshal_load_frozen
+ r = Random.new(0)
+ d = r.marshal_dump
+ r.freeze
+ assert_raise(RuntimeError, '[Bug #6540]') do
+ r.marshal_load(d)
+ end
+ end
+
+ def test_marshal_load_insecure
+ r = Random.new(0)
+ d = r.marshal_dump
+ l = proc do
+ $SAFE = 4
+ r.marshal_load(d)
+ end
+ assert_raise(SecurityError, '[Bug #6540]') do
+ l.call
+ end
+ end
end