summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:32:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 04:32:39 +0000
commit77898c33e38be4333112986f9f4f68867f8ce7ca (patch)
tree374f6539d4aab9d7820d01ccce87fee62846e49d /error.c
parent47c6131b2987fe6158ebca009746a88e3c1b6a77 (diff)
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
Diffstat (limited to 'error.c')
-rw-r--r--error.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/error.c b/error.c
index a1987fec95..09921361cf 100644
--- a/error.c
+++ b/error.c
@@ -2011,6 +2011,21 @@ rb_check_trusted(VALUE 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)
{
rb_eNOERROR = set_syserr(0, "NOERROR");