diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-17 07:26:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-17 07:26:45 +0000 |
commit | e2fd80b3d3b7f8ca7ffc2e7286fdb59e0c44bc79 (patch) | |
tree | 58bc2b44f4aed3cb90f5a1b45ea6ef25aff4ec52 /test/ruby/test_struct.rb | |
parent | 18f0a65018dd357a1815941618d3cf9f274e6239 (diff) |
* error.c (rb_check_trusted): new function to check an object is
trusted.
* struct.c (rb_struct_modify), time.c (time_modify): check by the
above function to show proper class names. [Bug #5036]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r-- | test/ruby/test_struct.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 49dcdb45b2..d769e47dc5 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -1,5 +1,6 @@ require 'test/unit' require 'timeout' +require_relative 'envutil' class TestStruct < Test::Unit::TestCase def test_struct @@ -249,4 +250,17 @@ class TestStruct < Test::Unit::TestCase assert !x.eql?(z) } end + + def test_struct_subclass + bug5036 = '[ruby-dev:44122]' + st = Class.new(Struct) + s = st.new("S", :m).new + error = assert_raise(SecurityError) do + proc do + $SAFE = 4 + s.m = 1 + end.call + end + assert_equal("Insecure: can't modify #{st}::S", error.message, bug5036) + end end |