diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-19 07:41:24 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-19 07:41:24 +0000 |
commit | b3ad0d22902ca5fe62f81a94807e023c6641953c (patch) | |
tree | 85dc5a57834e7539c4f28403f7150c562fabb8e6 /eval.c | |
parent | 74848dd1dc8541f40f0257f5b450a12af947bd70 (diff) |
commit miss; sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 88 |
1 files changed, 50 insertions, 38 deletions
@@ -1296,6 +1296,34 @@ rb_eval_string_wrap(str, state) return val; } +static void +jump_tag_but_local_jump(state) + int state; +{ + switch (state) { + case 0: + break; + case TAG_RETURN: + rb_raise(rb_eLocalJumpError, "unexpected return"); + break; + case TAG_NEXT: + rb_raise(rb_eLocalJumpError, "unexpected next"); + break; + case TAG_BREAK: + rb_raise(rb_eLocalJumpError, "unexpected break"); + break; + case TAG_REDO: + rb_raise(rb_eLocalJumpError, "unexpected redo"); + break; + case TAG_RETRY: + rb_raise(rb_eLocalJumpError, "retry outside of rescue clause"); + break; + default: + JUMP_TAG(state); + break; + } +} + VALUE rb_eval_cmd(cmd, arg) VALUE cmd, arg; @@ -1331,28 +1359,7 @@ rb_eval_cmd(cmd, arg) POP_TAG(); POP_CLASS(); - switch (state) { - case 0: - break; - case TAG_RETURN: - rb_raise(rb_eLocalJumpError, "unexpected return"); - break; - case TAG_NEXT: - rb_raise(rb_eLocalJumpError, "unexpected next"); - break; - case TAG_BREAK: - rb_raise(rb_eLocalJumpError, "unexpected break"); - break; - case TAG_REDO: - rb_raise(rb_eLocalJumpError, "unexpected redo"); - break; - case TAG_RETRY: - rb_raise(rb_eLocalJumpError, "retry outside of rescue clause"); - break; - default: - JUMP_TAG(state); - break; - } + jump_tag_but_local_jump(state); return val; } @@ -3642,10 +3649,8 @@ rb_yield_0(val, self, klass, acheck) if (!block->tag) { switch (state & TAG_MASK) { case TAG_BREAK: - rb_raise(rb_eLocalJumpError, "unexpected break"); - break; case TAG_RETURN: - rb_raise(rb_eLocalJumpError, "unexpected return"); + jump_tag_but_local_jump(state & TAG_MASK); break; } } @@ -4452,21 +4457,14 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper) case 0: break; - case TAG_NEXT: - rb_raise(rb_eLocalJumpError, "unexpected next"); - break; - case TAG_BREAK: - rb_raise(rb_eLocalJumpError, "unexpected break"); - break; - case TAG_REDO: - rb_raise(rb_eLocalJumpError, "unexpected redo"); - break; case TAG_RETRY: - if (!rb_block_given_p()) { - rb_raise(rb_eLocalJumpError, "retry outside of rescue clause"); + if (rb_block_given_p()) { + break; } + /* fall through */ default: - JUMP_TAG(state); + jump_tag_but_local_jump(state); + break; } } } @@ -5187,7 +5185,7 @@ rb_load(fname, wrap) rb_exc_raise(ruby_errinfo); } TMP_PROTECT_END; - if (state) JUMP_TAG(state); + if (state) jump_tag_but_local_jump(state); if (!NIL_P(ruby_errinfo)) /* exception during load */ rb_exc_raise(ruby_errinfo); } @@ -5427,6 +5425,15 @@ rb_require(fname) } static void +secure_visibility(self) + VALUE self; +{ + if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) { + rb_raise(rb_eSecurityError, "Insecure: can't change method visibility"); + } +} + +static void set_method_visibility(self, argc, argv, ex) VALUE self; int argc; @@ -5435,6 +5442,7 @@ set_method_visibility(self, argc, argv, ex) { int i; + secure_visibility(self); for (i=0; i<argc; i++) { rb_export_method(self, rb_to_id(argv[i]), ex); } @@ -5446,6 +5454,7 @@ rb_mod_public(argc, argv, module) VALUE *argv; VALUE module; { + secure_visibility(module); if (argc == 0) { SCOPE_SET(SCOPE_PUBLIC); } @@ -5461,6 +5470,7 @@ rb_mod_protected(argc, argv, module) VALUE *argv; VALUE module; { + secure_visibility(module); if (argc == 0) { SCOPE_SET(SCOPE_PROTECTED); } @@ -5476,6 +5486,7 @@ rb_mod_private(argc, argv, module) VALUE *argv; VALUE module; { + secure_visibility(module); if (argc == 0) { SCOPE_SET(SCOPE_PRIVATE); } @@ -5535,6 +5546,7 @@ rb_mod_modfunc(argc, argv, module) rb_raise(rb_eTypeError, "module_function must be called for modules"); } + secure_visibility(module); if (argc == 0) { SCOPE_SET(SCOPE_MODFUNC); return module; |