1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_trace.c: TracePoint safe level check

* vm_trace.c (rb_tracepoint_enable, rb_tracepoint_disable): check safe
  level as well as set_trace_func.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-01-29 07:51:00 +00:00
parent e26c2bc21b
commit 499ca89e24
3 changed files with 26 additions and 3 deletions

View file

@ -1,4 +1,7 @@
Tue Jan 29 16:50:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
Tue Jan 29 16:50:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_trace.c (rb_tracepoint_enable, rb_tracepoint_disable): check safe
level as well as set_trace_func.
* vm_trace.c (set_trace_func, thread_{add,set}_trace_func_m): check
safe level as well as 1.8.

View file

@ -919,4 +919,18 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal([:b_call, :b_return], ary, bug_7668)
end
end
def test_trace_point_enable_safe4
tp = TracePoint.new {}
assert_security_error_safe4 do
tp.enable
end
end
def test_trace_point_disable_safe4
tp = TracePoint.new {}
assert_security_error_safe4 do
tp.disable
end
end
end

View file

@ -943,7 +943,10 @@ tp_call_trace(VALUE tpval, rb_trace_arg_t *trace_arg)
VALUE
rb_tracepoint_enable(VALUE tpval)
{
rb_tp_t *tp = tpptr(tpval);
rb_tp_t *tp;
rb_secure(4);
tp = tpptr(tpval);
if (tp->target_th) {
rb_thread_add_event_hook2(tp->target_th->self, (rb_event_hook_func_t)tp_call_trace, tp->events, tpval,
@ -960,7 +963,10 @@ rb_tracepoint_enable(VALUE tpval)
VALUE
rb_tracepoint_disable(VALUE tpval)
{
rb_tp_t *tp = tpptr(tpval);
rb_tp_t *tp;
rb_secure(4);
tp = tpptr(tpval);
if (tp->target_th) {
rb_thread_remove_event_hook_with_data(tp->target_th->self, (rb_event_hook_func_t)tp_call_trace, tpval);