Permalink
Browse files

sprintf.c: infect

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent bb545e2 commit 665b06ec5bf747c13ff7c5fa9b003d5ca2540709 @nobu nobu committed Aug 15, 2012
Showing with 24 additions and 4 deletions.
  1. +1 −4 ChangeLog
  2. +1 −0 sprintf.c
  3. +22 −0 test/-ext-/test_printf.rb
View
@@ -1,7 +1,4 @@
-Wed Aug 15 16:23:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * sprintf.c (ruby__sfvwrite): set buffer length and exclude
- uninitialized garbage to get correct coderange.
+Wed Aug 15 16:26:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (ruby__sfvextra): the result should be infected by the
given strings.
View
@@ -1210,6 +1210,7 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
StringValueCStr(value);
RSTRING_GETMEM(value, cp, *sz);
((rb_printf_buffer_extra *)fp)->value = value;
+ OBJ_INFECT(result, value);
return cp;
}
@@ -28,4 +28,26 @@ def self.to_s
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

0 comments on commit 665b06e

Please sign in to comment.