зеркало из https://github.com/github/ruby.git
random.c, rational.c: make marshal methods private
* random.c (Init_Random), rational.c (Init_Rational): make marshal methods private. [Feature #6539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c4f9dd2626
Коммит
4d73f95068
|
@ -1,3 +1,8 @@
|
|||
Mon Dec 3 19:10:12 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (Init_Random), rational.c (Init_Rational): make marshal
|
||||
methods private. [Feature #6539]
|
||||
|
||||
Mon Dec 3 18:29:27 2012 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* iseq.h: iseq_catch_table_entry::catch_type should be
|
||||
|
|
4
random.c
4
random.c
|
@ -1463,8 +1463,8 @@ Init_Random(void)
|
|||
rb_define_method(rb_cRandom, "bytes", random_bytes, 1);
|
||||
rb_define_method(rb_cRandom, "seed", random_get_seed, 0);
|
||||
rb_define_method(rb_cRandom, "initialize_copy", random_copy, 1);
|
||||
rb_define_method(rb_cRandom, "marshal_dump", random_dump, 0);
|
||||
rb_define_method(rb_cRandom, "marshal_load", random_load, 1);
|
||||
rb_define_private_method(rb_cRandom, "marshal_dump", random_dump, 0);
|
||||
rb_define_private_method(rb_cRandom, "marshal_load", random_load, 1);
|
||||
rb_define_private_method(rb_cRandom, "state", random_state, 0);
|
||||
rb_define_private_method(rb_cRandom, "left", random_left, 0);
|
||||
rb_define_method(rb_cRandom, "==", random_equal, 1);
|
||||
|
|
|
@ -2432,9 +2432,9 @@ Init_Rational(void)
|
|||
rb_define_method(rb_cRational, "to_s", nurat_to_s, 0);
|
||||
rb_define_method(rb_cRational, "inspect", nurat_inspect, 0);
|
||||
|
||||
rb_define_method(rb_cRational, "marshal_dump", nurat_marshal_dump, 0);
|
||||
rb_define_private_method(rb_cRational, "marshal_dump", nurat_marshal_dump, 0);
|
||||
compat = rb_define_class_under(rb_cRational, "compatible", rb_cObject);
|
||||
rb_define_method(compat, "marshal_load", nurat_marshal_load, 1);
|
||||
rb_define_private_method(compat, "marshal_load", nurat_marshal_load, 1);
|
||||
rb_marshal_define_compat(rb_cRational, compat, nurat_dumper, nurat_loader);
|
||||
|
||||
/* --- */
|
||||
|
|
|
@ -482,7 +482,7 @@ END
|
|||
def test_marshal
|
||||
bug3656 = '[ruby-core:31622]'
|
||||
assert_raise(TypeError, bug3656) {
|
||||
Random.new.marshal_load(0)
|
||||
Random.new.__send__(:marshal_load, 0)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -496,19 +496,19 @@ END
|
|||
|
||||
def test_marshal_load_frozen
|
||||
r = Random.new(0)
|
||||
d = r.marshal_dump
|
||||
d = r.__send__(:marshal_dump)
|
||||
r.freeze
|
||||
assert_raise(RuntimeError, '[Bug #6540]') do
|
||||
r.marshal_load(d)
|
||||
r.__send__(:marshal_load, d)
|
||||
end
|
||||
end
|
||||
|
||||
def test_marshal_load_insecure
|
||||
r = Random.new(0)
|
||||
d = r.marshal_dump
|
||||
d = r.__send__(:marshal_dump)
|
||||
l = proc do
|
||||
$SAFE = 4
|
||||
r.marshal_load(d)
|
||||
r.__send__(:marshal_load, d)
|
||||
end
|
||||
assert_raise(SecurityError, '[Bug #6540]') do
|
||||
l.call
|
||||
|
|
Загрузка…
Ссылка в новой задаче