From 12185d8efa6208481629643bcfeba4b50c0c0253 Mon Sep 17 00:00:00 2001 From: yugui Date: Sat, 8 Aug 2009 15:33:47 +0000 Subject: merges r24396 from trunk into ruby_1_9_1. -- * lib/pp.rb (guard_inspect_key): untrust internal hash to prevent unexpected SecurityError. * test/ruby/test_object.rb: add a test for [ruby-dev:38982]. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/pp.rb | 6 +++--- test/ruby/test_object.rb | 36 ++++++++++++++++++++++++++++++++++++ version.h | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b47026276..10307b867 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Aug 5 01:38:27 2009 Yusuke Endoh + + * lib/pp.rb (guard_inspect_key): untrust internal hash to prevent + unexpected SecurityError. + + * test/ruby/test_object.rb: add a test for [ruby-dev:38982]. + Tue Aug 4 22:10:34 2009 NAKAMURA Usaku * win32/win32.c (has_redirection): need to execute shell if commandline diff --git a/lib/pp.rb b/lib/pp.rb index 41f51b004..d29dd299c 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -107,17 +107,17 @@ class PP < PrettyPrint module PPMethods def guard_inspect_key if Thread.current[:__recursive_key__] == nil - Thread.current[:__recursive_key__] = {} + Thread.current[:__recursive_key__] = {}.untrust end if Thread.current[:__recursive_key__][:inspect] == nil - Thread.current[:__recursive_key__][:inspect] = {} + Thread.current[:__recursive_key__][:inspect] = {}.untrust end save = Thread.current[:__recursive_key__][:inspect] begin - Thread.current[:__recursive_key__][:inspect] = {} + Thread.current[:__recursive_key__][:inspect] = {}.untrust yield ensure Thread.current[:__recursive_key__][:inspect] = save diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 2116c6a21..14f189685 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -405,4 +405,40 @@ class TestObject < Test::Unit::TestCase assert_equal(true, s.untrusted?) assert_equal(true, s.tainted?) end + + def test_exec_recursive + Thread.current[:__recursive_key__] = nil + a = [[]] + a.inspect + + assert_nothing_raised do + -> do + $SAFE = 4 + begin + a.hash + rescue ArgumentError + end + end.call + end + + -> do + assert_nothing_raised do + $SAFE = 4 + a.inspect + end + end.call + + -> do + o = Object.new + def o.to_ary(x); end + def o.==(x); $SAFE = 4; false; end + a = [[o]] + b = [] + b << b + + assert_nothing_raised do + b == a + end + end.call + end end diff --git a/version.h b/version.h index 553a50f7e..4cd151c7a 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 270 +#define RUBY_PATCHLEVEL 271 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit