summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_settracefunc.rb14
-rw-r--r--vm_trace.c10
3 files changed, 26 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cd67e0ec0d..8bc8fa3ae9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 264b805127d..e7c010aaaf9 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -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
diff --git a/vm_trace.c b/vm_trace.c
index 36fa2327ea0..dd68715693d 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -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);