mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
bb545e2131
commit
665b06ec5b
3 changed files with 24 additions and 4 deletions
|
@ -1,7 +1,4 @@
|
||||||
Wed Aug 15 16:23:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Aug 15 16:26:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* 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
|
* sprintf.c (ruby__sfvextra): the result should be infected by the
|
||||||
given strings.
|
given strings.
|
||||||
|
|
|
@ -1210,6 +1210,7 @@ ruby__sfvextra(rb_printf_buffer *fp, size_t valsize, void *valp, long *sz, int s
|
||||||
StringValueCStr(value);
|
StringValueCStr(value);
|
||||||
RSTRING_GETMEM(value, cp, *sz);
|
RSTRING_GETMEM(value, cp, *sz);
|
||||||
((rb_printf_buffer_extra *)fp)->value = value;
|
((rb_printf_buffer_extra *)fp)->value = value;
|
||||||
|
OBJ_INFECT(result, value);
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,26 @@ class Test_SPrintf < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
|
assert_equal("<\u{3042 3044 3046 3048 304a}>", Bug::Printf.s(self))
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue