summaryrefslogtreecommitdiff
path: root/ext/dl/cptr.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-11 11:33:44 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-11 11:33:44 +0000
commit199a95775b4f0e8d7ecab2946b8d7c250a695f40 (patch)
tree623e6cac5cbf684b9066f66b4c5aae7375439f86 /ext/dl/cptr.c
parent35b6abbca2cb419aae599d04e5855e33a97935dd (diff)
* ext/dl/cfunc.c (rb_dlcfunc_call): add taint check.
* ext/dl/dl.c (rb_dl_malloc): add rb_secure(2). * ext/dl/dl.c (rb_dl_realloc): ditto. * ext/dl/dl.c (rb_dl_free): ditto. * ext/dl/dl.c (rb_dl_ptr2value): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/cptr.c')
-rw-r--r--ext/dl/cptr.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
index aeb1852b48..b5f1e239e4 100644
--- a/ext/dl/cptr.c
+++ b/ext/dl/cptr.c
@@ -416,29 +416,33 @@ rb_dlptr_size(int argc, VALUE argv[], VALUE self)
VALUE
rb_dlptr_s_to_ptr(VALUE self, VALUE val)
{
- if( rb_obj_is_kind_of(val, rb_cIO) == Qtrue ){
+ VALUE ptr;
+
+ if (rb_obj_is_kind_of(val, rb_cIO) == Qtrue){
rb_io_t *fptr;
FILE *fp;
GetOpenFile(val, fptr);
fp = rb_io_stdio_file(fptr);
- return rb_dlptr_new(fp, 0, NULL);
+ ptr = rb_dlptr_new(fp, 0, NULL);
}
- else if( rb_obj_is_kind_of(val, rb_cString) == Qtrue ){
+ else if (rb_obj_is_kind_of(val, rb_cString) == Qtrue){
char *ptr = StringValuePtr(val);
- return rb_dlptr_new(ptr, RSTRING_LEN(val), NULL);
+ ptr = rb_dlptr_new(ptr, RSTRING_LEN(val), NULL);
}
- else if( rb_respond_to(val, id_to_ptr) ){
+ else if (rb_respond_to(val, id_to_ptr)){
VALUE vptr = rb_funcall(val, id_to_ptr, 0);
- if( rb_obj_is_kind_of(vptr, rb_cDLCPtr) ){
- return vptr;
+ if (rb_obj_is_kind_of(vptr, rb_cDLCPtr)){
+ ptr = vptr;
}
else{
rb_raise(rb_eDLError, "to_ptr should return a CPtr object");
}
}
else{
- return rb_dlptr_new(NUM2PTR(rb_Integer(val)), 0, NULL);
+ ptr = rb_dlptr_new(NUM2PTR(rb_Integer(val)), 0, NULL);
}
+ OBJ_INFECT(ptr, val);
+ return ptr;
}
void