Bug #5036 » fix-error-messages.patch
struct.c | ||
---|---|---|
{
|
||
rb_check_frozen(s);
|
||
if (!OBJ_UNTRUSTED(s) && rb_safe_level() >= 4)
|
||
rb_raise(rb_eSecurityError, "Insecure: can't modify Struct");
|
||
rb_raise(rb_eSecurityError, "Insecure: can't modify %s", rb_obj_classname(s));
|
||
}
|
||
static VALUE
|
time.c | ||
---|---|---|
{
|
||
rb_check_frozen(time);
|
||
if (!OBJ_UNTRUSTED(time) && rb_safe_level() >= 4)
|
||
rb_raise(rb_eSecurityError, "Insecure: can't modify Time");
|
||
rb_raise(rb_eSecurityError, "Insecure: can't modify %s", rb_obj_classname(time));
|
||
}
|
||
static wideval_t
|
test/ruby/test_struct.rb | ||
---|---|---|
require 'test/unit'
|
||
require 'timeout'
|
||
require_relative 'envutil'
|
||
class TestStruct < Test::Unit::TestCase
|
||
def test_struct
|
||
... | ... | |
assert !x.eql?(z)
|
||
}
|
||
end
|
||
def test_struct_subclass
|
||
bugNNNN = '[ruby-dev:NNNN]'
|
||
assert_in_out_err([], <<-INPUT, [], /Insecure: can't modify Struct2::S \(SecurityError\)$/, bugNNNN)
|
||
Thread.new do
|
||
class Struct2 < Struct
|
||
end
|
||
s = Struct2.new("S", :m).new
|
||
$SAFE=4
|
||
s.m=1
|
||
end.join
|
||
INPUT
|
||
end
|
||
end
|
test/ruby/test_time.rb | ||
---|---|---|
require 'delegate'
|
||
require 'timeout'
|
||
require 'delegate'
|
||
require_relative 'envutil'
|
||
class TestTime < Test::Unit::TestCase
|
||
def setup
|
||
... | ... | |
assert_raise(NoMethodError, bug5012) { t1.m }
|
||
end
|
||
def test_time_subclass
|
||
bugNNNN = '[ruby-dev:NNNN]'
|
||
assert_in_out_err([], <<-INPUT, [], /Insecure: can't modify Time2 \(SecurityError\)$/, bugNNNN)
|
||
Thread.new do
|
||
class Time2 < Time
|
||
end
|
||
t = Time2.now
|
||
$SAFE=4
|
||
t.gmtime
|
||
end.join
|
||
INPUT
|
||
end
|
||
end
|