summaryrefslogtreecommitdiff
path: root/ext/fiddle
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-14 11:06:58 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-14 11:06:58 +0000
commitc7d7ff45f1e0d6fad28e53c02108d4b067e843c3 (patch)
treed60cb2e9a20860bff7c8acc9422b7f1221b288dc /ext/fiddle
parent912c16db3dae29fb473152d8861ec7afcf2964b7 (diff)
* ext/dl/lib/dl/func.rb (DL::Function#call): check tainted when
$SAFE > 0. * ext/fiddle/function.c (function_call): check tainted when $SAFE > 0. * test/fiddle/test_func.rb (module Fiddle): add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/fiddle')
-rw-r--r--ext/fiddle/function.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 72a1a62..4a5a589 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -126,6 +126,15 @@ function_call(int argc, VALUE argv[], VALUE self)
TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif);
+ if (rb_safe_level() >= 1) {
+ for (i = 0; i < argc; i++) {
+ VALUE src = argv[i];
+ if (OBJ_TAINTED(src)) {
+ rb_raise(rb_eSecurityError, "tainted parameter not allowed");
+ }
+ }
+ }
+
values = xcalloc((size_t)argc + 1, (size_t)sizeof(void *));
generic_args = xcalloc((size_t)argc, (size_t)sizeof(fiddle_generic));