summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:36:54 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:36:54 (GMT)
commit0b0dea752c0ef35d1a964b812a1a7fd033ab9e2e (patch)
tree5809b3a6a5fe233e25fccfd532f447c82fd67e8a /random.c
parent77898c33e38be4333112986f9f4f68867f8ce7ca (diff)
random.c: check initialize and load
* random.c (random_init, random_load): cannot initialize frozen object again, nor with tainted/untrusted object. [Bug #6540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/random.c b/random.c
index 7244a00..197a80f 100644
--- a/random.c
+++ b/random.c
@@ -462,10 +462,12 @@ random_init(int argc, VALUE *argv, VALUE obj)
rb_random_t *rnd = get_rnd(obj);
if (argc == 0) {
+ rb_check_frozen(obj);
vseed = random_seed();
}
else {
rb_scan_args(argc, argv, "01", &vseed);
+ rb_check_copyable(obj, vseed);
}
rnd->seed = rand_init(&rnd->mt, vseed);
return obj;
@@ -686,6 +688,7 @@ random_load(VALUE obj, VALUE dump)
VALUE *ary;
unsigned long x;
+ rb_check_copyable(obj, dump);
Check_Type(dump, T_ARRAY);
ary = RARRAY_PTR(dump);
switch (RARRAY_LEN(dump)) {