[macruby-changes] [4996] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 8 09:08:47 PST 2010


Revision: 4996
          http://trac.macosforge.org/projects/ruby/changeset/4996
Author:   watson1978 at gmail.com
Date:     2010-12-08 09:08:44 -0800 (Wed, 08 Dec 2010)
Log Message:
-----------
Array#pack will return a untrusted string when the format is untrusted

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

ary = ["abcd", 0x20]
fmt = "A3C"
fmt.untrust
fmt.taint

ret = ary.pack(fmt)
assert_equal("abc ", ret)
assert_equal(true,   ret.tainted?)
assert_equal(true,   ret.untrusted?)

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/pack.c
    MacRuby/trunk/spec/frozen/tags/macruby/core/array/pack_tags.txt

Modified: MacRuby/trunk/pack.c
===================================================================
--- MacRuby/trunk/pack.c	2010-12-08 14:51:28 UTC (rev 4995)
+++ MacRuby/trunk/pack.c	2010-12-08 17:08:44 UTC (rev 4996)
@@ -1032,19 +1032,7 @@
 	}
     }
 
-    // Taint the ByteString accordingly.
-    if (OBJ_TAINTED(fmt)) {
-	OBJ_TAINT(data);
-    }
-    else {
-	for (long i = 0, count = RARRAY_LEN(ary); i < count; i++) {
-	    if (OBJ_TAINTED(RARRAY_AT(ary, i))) {
-		OBJ_TAINT(data);
-		break;
-	    }
-	}
-    }
-
+    OBJ_INFECT(data, fmt);
     switch (enc_info) {
       case 1:
 	// TODO

Modified: MacRuby/trunk/spec/frozen/tags/macruby/core/array/pack_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/macruby/core/array/pack_tags.txt	2010-12-08 14:51:28 UTC (rev 4995)
+++ MacRuby/trunk/spec/frozen/tags/macruby/core/array/pack_tags.txt	2010-12-08 17:08:44 UTC (rev 4996)
@@ -1,5 +1,3 @@
-fails:Array#pack returns a untrusted string when the format is untrusted
-fails:Array#pack returns a untrusted string when the format is untrusted even if the given format is empty
 fails:Array#pack with the empty format returns an empty String in US-ASCII
 fails:Array#pack with format 'A' treats a multibyte character just as a byte sequence
 fails:Array#pack with format 'A' returns result in ASCII-8BIT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101208/ac214cfc/attachment.html>


More information about the macruby-changes mailing list