Permalink
Browse files

r{ary,str,hash}_modify: check for the unstrust flag properly

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5194 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 05be8be commit f39c792e94401bf8e7165681974d384494be66fc @lrz lrz committed Jan 28, 2011
Showing with 9 additions and 6 deletions.
  1. +7 −4 array.h
  2. +1 −1 encoding.h
  3. +1 −1 hash.h
View
11 array.h
@@ -45,11 +45,14 @@ rb_klass_is_rary(VALUE klass)
static inline void
rary_modify(VALUE ary)
{
- if (OBJ_FROZEN(ary)) {
- rb_error_frozen("array");
+ const long mask = RBASIC(ary)->flags;
+ if ((mask & FL_FREEZE) == FL_FREEZE) {
+ rb_raise(rb_eRuntimeError, "can't modify frozen/immutable array");
}
- if (!OBJ_UNTRUSTED(ary) && rb_safe_level() >= 4) {
- rb_raise(rb_eSecurityError, "Insecure: can't modify array");
+ if ((mask & FL_UNTRUSTED) != FL_UNTRUSTED) {
+ if (rb_safe_level() >= 4) {
+ rb_raise(rb_eSecurityError, "Insecure: can't modify array");
+ }
}
}
View
2 encoding.h
@@ -88,7 +88,7 @@ rstr_modify(VALUE str)
if ((mask & FL_FREEZE) == FL_FREEZE) {
rb_raise(rb_eRuntimeError, "can't modify frozen/immutable string");
}
- if ((mask & FL_TAINT) == FL_TAINT) {
+ if ((mask & FL_UNTRUSTED) != FL_UNTRUSTED) {
if (rb_safe_level() >= 4) {
rb_raise(rb_eSecurityError, "Insecure: can't modify string");
}
View
2 hash.h
@@ -45,7 +45,7 @@ rhash_modify(VALUE hash)
if ((mask & FL_FREEZE) == FL_FREEZE) {
rb_raise(rb_eRuntimeError, "can't modify frozen/immutable hash");
}
- if ((mask & FL_UNTRUSTED) == FL_UNTRUSTED) {
+ if ((mask & FL_UNTRUSTED) != FL_UNTRUSTED) {
if (rb_safe_level() >= 4) {
rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
}

0 comments on commit f39c792

Please sign in to comment.