summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-24 07:56:37 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-24 07:56:37 +0000
commitab7dac4027c063222ad5e4ea68012020f97c047d (patch)
treec5df9566e9f8fd8853275059bf9056a954420d6b /ext
parente5282ef182fbd11e2cfd41b752003367320e409f (diff)
Added rb_secure(4). (Thanks to Minero Aoki)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-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 0d806a7de78..bfdf5e81a6d 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 60f4ad00edf..a7a9aebbd69 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 95a813cc1f8..7e18e61b5e9 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);