[macruby-changes] [5194] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Jan 27 18:58:24 PST 2011


Revision: 5194
          http://trac.macosforge.org/projects/ruby/changeset/5194
Author:   lsansonetti at apple.com
Date:     2011-01-27 18:58:24 -0800 (Thu, 27 Jan 2011)
Log Message:
-----------
r{ary,str,hash}_modify: check for the unstrust flag properly

Modified Paths:
--------------
    MacRuby/trunk/array.h
    MacRuby/trunk/encoding.h
    MacRuby/trunk/hash.h

Modified: MacRuby/trunk/array.h
===================================================================
--- MacRuby/trunk/array.h	2011-01-28 02:36:05 UTC (rev 5193)
+++ MacRuby/trunk/array.h	2011-01-28 02:58:24 UTC (rev 5194)
@@ -45,11 +45,14 @@
 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");
+        }
     }
 }
 

Modified: MacRuby/trunk/encoding.h
===================================================================
--- MacRuby/trunk/encoding.h	2011-01-28 02:36:05 UTC (rev 5193)
+++ MacRuby/trunk/encoding.h	2011-01-28 02:58:24 UTC (rev 5194)
@@ -88,7 +88,7 @@
     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");
 	}

Modified: MacRuby/trunk/hash.h
===================================================================
--- MacRuby/trunk/hash.h	2011-01-28 02:36:05 UTC (rev 5193)
+++ MacRuby/trunk/hash.h	2011-01-28 02:58:24 UTC (rev 5194)
@@ -45,7 +45,7 @@
     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");
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110127/78727f22/attachment-0001.html>


More information about the macruby-changes mailing list