ext/ffi_c/Call.c in ffi-1.1.6.pre2 vs ext/ffi_c/Call.c in ffi-1.2.0.dev
- old
+ new
@@ -312,14 +312,12 @@
retval = alloca(MAX(fnInfo->ffi_cif.rtype->size, FFI_SIZEOF_ARG));
if (unlikely(fnInfo->blocking)) {
BlockingCall* bc;
- /*
- * due to the way thread switching works on older ruby variants, we
- * cannot allocate anything passed to the blocking function on the stack
- */
+ // due to the way thread switching works on older ruby variants, we
+ // cannot allocate anything passed to the blocking function on the stack
ffiValues = ALLOC_N(void *, fnInfo->parameterCount);
params = ALLOC_N(FFIStorage, fnInfo->parameterCount);
bc = ALLOC_N(BlockingCall, 1);
bc->info = fnInfo;
bc->function = function;
@@ -375,11 +373,14 @@
AbstractMemory* memory = ((Struct *) DATA_PTR(value))->pointer;
return memory != NULL ? memory->address : NULL;
} else if (type == T_STRING) {
-
+
+ if (rb_safe_level() >= 1 && OBJ_TAINTED(value)) {
+ rb_raise(rb_eSecurityError, "Unsafe string parameter");
+ }
return StringValuePtr(value);
} else if (type == T_NIL) {
return NULL;
@@ -429,16 +430,17 @@
VALUE callback ;
if (unlikely(proc == Qnil)) {
return NULL ;
}
- /* Handle Function pointers here */
+ // Handle Function pointers here
if (rb_obj_is_kind_of(proc, rbffi_FunctionClass)) {
AbstractMemory* ptr;
Data_Get_Struct(proc, AbstractMemory, ptr);
return ptr->address;
}
+ //callback = rbffi_NativeCallback_ForProc(proc, cbInfo);
callback = rbffi_Function_ForProc(cbInfo, proc);
RB_GC_GUARD(callback);
return ((AbstractMemory *) DATA_PTR(callback))->address;
}