summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-17 07:26:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-17 07:26:45 +0000
commite2fd80b3d3b7f8ca7ffc2e7286fdb59e0c44bc79 (patch)
tree58bc2b44f4aed3cb90f5a1b45ea6ef25aff4ec52 /error.c
parent18f0a65018dd357a1815941618d3cf9f274e6239 (diff)
* error.c (rb_check_trusted): new function to check an object is
trusted. * struct.c (rb_struct_modify), time.c (time_modify): check by the above function to show proper class names. [Bug #5036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/error.c b/error.c
index 53f5472efc..42f83682ea 100644
--- a/error.c
+++ b/error.c
@@ -1715,6 +1715,22 @@ rb_check_frozen(VALUE obj)
}
void
+rb_error_untrusted(VALUE obj)
+{
+ if (rb_safe_level() >= 4) {
+ rb_raise(rb_eSecurityError, "Insecure: can't modify %s",
+ rb_obj_classname(obj));
+ }
+}
+
+#undef rb_check_trusted
+void
+rb_check_trusted(VALUE obj)
+{
+ rb_check_trusted_internal(obj);
+}
+
+void
Init_syserr(void)
{
rb_eNOERROR = set_syserr(0, "NOERROR");