summaryrefslogtreecommitdiff
path: root/ext/dl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl')
-rw-r--r--ext/dl/dl.c9
-rw-r--r--ext/dl/ptr.c5
-rw-r--r--ext/dl/sym.c2
3 files changed, 15 insertions, 1 deletions
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index 0d806a7de7..bfdf5e81a6 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -542,18 +542,21 @@ rb_io_to_ptr(VALUE self)
VALUE
rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
{
+ rb_secure(4);
return rb_class_new_instance(argc, argv, rb_cDLHandle);
}
VALUE
rb_dl_malloc(VALUE self, VALUE size)
{
+ rb_secure(4);
return rb_dlptr_malloc(DLNUM2LONG(size), dlfree);
}
VALUE
rb_dl_strdup(VALUE self, VALUE str)
{
+ rb_secure(4);
str = rb_String(str);
return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
}
@@ -561,6 +564,7 @@ rb_dl_strdup(VALUE self, VALUE str)
static VALUE
rb_dl_sizeof(VALUE self, VALUE str)
{
+ rb_secure(4);
return INT2NUM(dlsizeof(StringValuePtr(str)));
}
@@ -571,6 +575,7 @@ rb_dl_callback(int argc, VALUE argv[], VALUE self)
int rettype, entry, i;
char fname[127];
+ rb_secure(4);
proc = Qnil;
switch( rb_scan_args(argc, argv, "11", &type, &proc) ){
case 1:
@@ -636,9 +641,11 @@ rb_dl_callback(int argc, VALUE argv[], VALUE self)
static VALUE
rb_dl_remove_callback(VALUE mod, VALUE sym)
{
- freefunc_t f = rb_dlsym2csym(sym);
+ freefunc_t f;
int i, j;
+ rb_secure(4);
+ f = rb_dlsym2csym(sym);
for( i=0; i < CALLBACK_TYPES; i++ ){
for( j=0; j < MAX_CALLBACK; j++ ){
if( rb_dl_callback_table[i][j] == f ){
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index 60f4ad00ed..a7a9aebbd6 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -26,6 +26,7 @@ rb_hash_delete(VALUE hash, VALUE key)
static void
rb_dlmem_delete(void *ptr)
{
+ rb_secure(4);
rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
}
@@ -89,6 +90,7 @@ rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
struct ptr_data *data;
VALUE val;
+ rb_secure(4);
if( ptr ){
val = rb_dlmem_aref(ptr);
if( val == Qnil ){
@@ -130,6 +132,7 @@ rb_dlptr_malloc(long size, freefunc_t func)
{
void *ptr;
+ rb_secure(4);
ptr = dlmalloc((size_t)size);
memset(ptr,0,(size_t)size);
return rb_dlptr_new(ptr, size, func);
@@ -161,6 +164,7 @@ rb_dlptr_s_allocate(VALUE klass)
VALUE obj;
struct ptr_data *data;
+ rb_secure(4);
obj = Data_Make_Struct(klass, struct ptr_data, 0, dlptr_free, data);
data->ptr = 0;
data->free = 0;
@@ -850,6 +854,7 @@ rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
long memsize;
void *memimg;
+ rb_secure(4);
switch( rb_scan_args(argc, argv, "21", &key, &num, &val) ){
case 2:
val = num;
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
index 95a813cc1f..7e18e61b5e 100644
--- a/ext/dl/sym.c
+++ b/ext/dl/sym.c
@@ -77,6 +77,7 @@ rb_dlsym_new(void (*func)(), const char *name, const char *type)
struct sym_data *data;
const char *ptype;
+ rb_secure(4);
if( !type || !type[0] ){
return rb_dlptr_new((void*)func, 0, 0);
}
@@ -329,6 +330,7 @@ rb_dlsym_call(int argc, VALUE argv[], VALUE self)
long ftype;
void *func;
+ rb_secure(4);
Data_Get_Struct(self, struct sym_data, sym);
DEBUG_CODE({
printf("rb_dlsym_call(): type = '%s', func = 0x%x\n", sym->type, sym->func);