ruby-changes:13663
From: tenderlove <ko1@a...>
Date: Sat, 24 Oct 2009 01:44:51 +0900 (JST)
Subject: [ruby-changes:13663] Ruby:r25448 (trunk): * ext/ext/dl/handle.c (rb_dlhandle_initialize) added rb_secure(2)
tenderlove 2009-10-24 01:44:41 +0900 (Sat, 24 Oct 2009) New Revision: 25448 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25448 Log: * ext/ext/dl/handle.c (rb_dlhandle_initialize) added rb_secure(2) [ruby-core:25762] * ext/dl/dl.c (rb_dl_dlopen) removed rb_secure(2) Added files: trunk/test/dl/test_handle.rb Modified files: trunk/ext/dl/dl.c trunk/ext/dl/handle.c Index: ext/dl/dl.c =================================================================== --- ext/dl/dl.c (revision 25447) +++ ext/dl/dl.c (revision 25448) @@ -13,7 +13,6 @@ VALUE rb_dl_dlopen(int argc, VALUE argv[], VALUE self) { - rb_secure(2); return rb_class_new_instance(argc, argv, rb_cDLHandle); } Index: ext/dl/handle.c =================================================================== --- ext/dl/handle.c (revision 25447) +++ ext/dl/handle.c (revision 25448) @@ -114,6 +114,8 @@ rb_bug("rb_dlhandle_new"); } + rb_secure(2); + #if defined(HAVE_WINDOWS_H) if( !clib ){ HANDLE rb_libruby_handle(void); Index: test/dl/test_handle.rb =================================================================== --- test/dl/test_handle.rb (revision 0) +++ test/dl/test_handle.rb (revision 25448) @@ -0,0 +1,27 @@ +require 'test_base' + +module DL + class TestHandle < TestBase + def test_dlopen_returns_handle + assert_instance_of DL::Handle, dlopen(LIBC_SO) + end + + def test_dlopen_safe + assert_raises(SecurityError) do + Thread.new do + $SAFE = 2 + dlopen(LIBC_SO) + end.join + end + end + + def test_initialize_safe + assert_raises(SecurityError) do + Thread.new do + $SAFE = 2 + DL::Handle.new(LIBC_SO) + end.join + end + end + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/