[前][次][番号順一覧][スレッド一覧]

ruby-changes:24656

From: nobu <ko1@a...>
Date: Wed, 15 Aug 2012 16:27:08 +0900 (JST)
Subject: [ruby-changes:24656] nobu:r36707 (trunk): sprintf.c: infect

nobu	2012-08-15 16:26:55 +0900 (Wed, 15 Aug 2012)

  New Revision: 36707

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36707

  Log:
    sprintf.c: infect
    
    * sprintf.c (ruby__sfvextra): the result should be infected by the
      given strings.

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c
    trunk/test/-ext-/test_printf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36706)
+++ ChangeLog	(revision 36707)
@@ -1,8 +1,5 @@
-Wed Aug 15 16:23:35 2012  Nobuyoshi Nakada  <nobu@r...>
+Wed Aug 15 16:26:52 2012  Nobuyoshi Nakada  <nobu@r...>
 
-	* sprintf.c (ruby__sfvwrite): set buffer length and exclude
-	  uninitialized garbage to get correct coderange.
-
 	* sprintf.c (ruby__sfvextra): the result should be infected by the
 	  given strings.
 
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 36706)
+++ sprintf.c	(revision 36707)
@@ -1210,6 +1210,7 @@
     StringValueCStr(value);
     RSTRING_GETMEM(value, cp, *sz);
     ((rb_printf_buffer_extra *)fp)->value = value;
+    OBJ_INFECT(result, value);
     return cp;
 }
 
Index: test/-ext-/test_printf.rb
===================================================================
--- test/-ext-/test_printf.rb	(revision 36706)
+++ test/-ext-/test_printf.rb	(revision 36707)
@@ -28,4 +28,26 @@
     end
     assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
   end
+
+  def test_taint
+    def self.to_s
+      super.taint
+    end
+    assert_equal({to_s: true, inspect: true},
+                 {
+                   to_s: Bug::Printf.s(self).tainted?,
+                   inspect: Bug::Printf.v(self).tainted?,
+                 })
+  end
+
+  def test_trust
+    def self.to_s
+      super.untrust
+    end
+    assert_equal({to_s: true, inspect: true},
+                 {
+                   to_s: Bug::Printf.s(self).untrusted?,
+                   inspect: Bug::Printf.v(self).untrusted?,
+                 })
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]