summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/dl/lib/dl/func.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb
index b29aebcc8b..a2e6d40fbe 100644
--- a/ext/dl/lib/dl/func.rb
+++ b/ext/dl/lib/dl/func.rb
@@ -25,8 +25,16 @@ module DL
@cfunc.to_i
end
+ def check_safe_obj(val)
+ if $SAFE > 0 and val.tainted?
+ raise SecurityError, 'Insecure operation'
+ end
+ end
+
def call(*args, &block)
funcs = []
+ args.each{|e| check_safe_obj(e) }
+ check_safe_obj(block)
args = wrap_args(args, @stack.types, funcs, &block)
r = @cfunc.call(@stack.pack(args))
funcs.each{|f| f.unbind_at_call()}