mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1eef1cdc56
commit
5ee251bdad
3 changed files with 29 additions and 1 deletions
|
@ -13,7 +13,6 @@ ID rbdl_id_stdcall;
|
||||||
VALUE
|
VALUE
|
||||||
rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
|
rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
|
||||||
{
|
{
|
||||||
rb_secure(2);
|
|
||||||
return rb_class_new_instance(argc, argv, rb_cDLHandle);
|
return rb_class_new_instance(argc, argv, rb_cDLHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,8 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
|
||||||
rb_bug("rb_dlhandle_new");
|
rb_bug("rb_dlhandle_new");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rb_secure(2);
|
||||||
|
|
||||||
#if defined(HAVE_WINDOWS_H)
|
#if defined(HAVE_WINDOWS_H)
|
||||||
if( !clib ){
|
if( !clib ){
|
||||||
HANDLE rb_libruby_handle(void);
|
HANDLE rb_libruby_handle(void);
|
||||||
|
|
27
test/dl/test_handle.rb
Normal file
27
test/dl/test_handle.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue