summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-18 14:12:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-18 14:12:42 +0000
commit52951aa59f8f9bc36823dbd3d545c670040bbefb (patch)
treeccbeb1630a04efeb8d680bc17cfcba5b248e2ffb
parentf339fb70d8bbbb0b89ae0465448c9f7e17f30c3b (diff)
downloadruby-52951aa59f8f9bc36823dbd3d545c670040bbefb.tar.gz
ruby-52951aa59f8f9bc36823dbd3d545c670040bbefb.tar.xz
ruby-52951aa59f8f9bc36823dbd3d545c670040bbefb.zip
* eval.c (proc_save_safe_level, rb_set_safe_level, safe_setter): limit
safe level. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c9
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1633f6214..d201a01a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 18 23:12:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (proc_save_safe_level, rb_set_safe_level, safe_setter): limit
+ safe level.
+
Wed Jun 16 23:05:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_mod_freeze): prepare string representation before
diff --git a/eval.c b/eval.c
index 42cef9df1..7b04b42e8 100644
--- a/eval.c
+++ b/eval.c
@@ -7896,12 +7896,17 @@ rb_f_binding(self)
#define PROC_TSHIFT (FL_USHIFT+1)
#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
+#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
+
+#define SAFE_LEVEL_MAX PROC_TMASK
static void
proc_save_safe_level(data)
VALUE data;
{
- FL_SET(data, (ruby_safe_level << PROC_TSHIFT) & PROC_TMASK);
+ int safe = ruby_safe_level;
+ if (safe > PROC_TMAX) safe = PROC_TMAX;
+ FL_SET(data, (safe << PROC_TSHIFT) & PROC_TMASK);
}
static int
@@ -9529,6 +9534,7 @@ rb_set_safe_level(level)
int level;
{
if (level > ruby_safe_level) {
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
ruby_safe_level = level;
curr_thread->safe = level;
}
@@ -9550,6 +9556,7 @@ safe_setter(val)
rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d",
ruby_safe_level, level);
}
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
ruby_safe_level = level;
curr_thread->safe = level;
}