diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-18 14:12:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-18 14:12:42 +0000 |
commit | 52951aa59f8f9bc36823dbd3d545c670040bbefb (patch) | |
tree | ccbeb1630a04efeb8d680bc17cfcba5b248e2ffb | |
parent | f339fb70d8bbbb0b89ae0465448c9f7e17f30c3b (diff) | |
download | ruby-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | eval.c | 9 |
2 files changed, 13 insertions, 1 deletions
@@ -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 @@ -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; } |