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

error.c: rb_check_copyable

* error.c (rb_check_copyable): new function, to ensure the target is
  not frozen and the source is not tainted nor untrusted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-06-22 04:32:39 +00:00
parent 47c6131b29
commit 77898c33e3
3 changed files with 21 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Fri Jun 22 13:32:33 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (rb_check_copyable): new function, to ensure the target is
not frozen and the source is not tainted nor untrusted.
Fri Jun 22 05:55:20 2012 Eric Hodel <drbrain@segment7.net>
* eval.c (ruby_cleanup): Fixed typo. Patch by Trever Dawe.

15
error.c
View file

@ -2010,6 +2010,21 @@ rb_check_trusted(VALUE obj)
rb_check_trusted_internal(obj);
}
void
rb_check_copyable(VALUE obj, VALUE orig)
{
if (!FL_ABLE(obj)) return;
rb_check_frozen_internal(obj);
rb_check_trusted_internal(obj);
if (!FL_ABLE(orig)) return;
if ((~RBASIC(obj)->flags & RBASIC(orig)->flags) & (FL_UNTRUSTED|FL_TAINT)) {
if (rb_safe_level() > 0) {
rb_raise(rb_eSecurityError, "Insecure: can't modify %"PRIsVALUE,
RBASIC(obj)->klass);
}
}
}
void
Init_syserr(void)
{

View file

@ -251,6 +251,7 @@ rb_check_trusted_inline(VALUE obj)
}
#define rb_check_trusted(obj) rb_check_trusted_inline(obj)
#endif
void rb_check_copyable(VALUE obj, VALUE orig);
#define OBJ_INIT_COPY(obj, orig) \
((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))