[macruby-changes] [1730] MacRuby/branches/experimental/pack.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 4 17:01:32 PDT 2009


Revision: 1730
          http://trac.macosforge.org/projects/ruby/changeset/1730
Author:   lsansonetti at apple.com
Date:     2009-06-04 17:01:32 -0700 (Thu, 04 Jun 2009)
Log Message:
-----------
better Array#pack taint magic

Modified Paths:
--------------
    MacRuby/branches/experimental/pack.c

Modified: MacRuby/branches/experimental/pack.c
===================================================================
--- MacRuby/branches/experimental/pack.c	2009-06-04 23:21:55 UTC (rev 1729)
+++ MacRuby/branches/experimental/pack.c	2009-06-05 00:01:32 UTC (rev 1730)
@@ -453,14 +453,25 @@
     pend = p + RSTRING_LEN(fmt);
 
     VALUE bres = rb_bytestring_new();
-    if (OBJ_TAINTED(fmt)) {
-	OBJ_TAINT(bres);
-    }
     CFMutableDataRef data = rb_bytestring_wrapped_data(bres);
 
     items = RARRAY_LEN(ary);
     idx = 0;
 
+    // Taint the ByteString accordingly.
+    if (OBJ_TAINTED(fmt)) {
+	OBJ_TAINT(bres);
+    }
+    else {
+	long i;
+	for (i = 0; i < items; i++) {
+	    if (OBJ_TAINTED(RARRAY_AT(ary, i))) {
+		OBJ_TAINT(bres);
+		break;
+	    }
+	}
+    }
+
 #define TOO_FEW (rb_raise(rb_eArgError, toofew), 0)
 #define THISFROM (items > 0 ? RARRAY_AT(ary, idx) : TOO_FEW)
 #define NEXTFROM (items-- > 0 ? RARRAY_AT(ary, idx++) : TOO_FEW)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090604/4e2c1f14/attachment.html>


More information about the macruby-changes mailing list