diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-06 16:15:59 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-06 16:15:59 +0000 |
commit | 58f77932a45873d691d9dab1f042da45822bd991 (patch) | |
tree | 6979e901bb0087cb34862042acad2dd13a9a1cac /test | |
parent | d309921ea54b54086ca20e57ab188528ef63023f (diff) |
merge revision(s) 54304: [Backport #12223]
* sprintf.c (rb_str_format): fix buffer overflow, length must be
greater than precision. reported by William Bowling <will AT
wbowling.info>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_sprintf.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 1d3badddf9..66ae4db853 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -172,6 +172,10 @@ class TestSprintf < Test::Unit::TestCase assert_equal("x"*10+" 1.0", sprintf("x"*10+"%8.1f", 1r)) end + def test_rational_precision + assert_match(/\A0\.\d{600}\z/, sprintf("%.600f", 600**~60)) + end + def test_hash options = {:capture=>/\d+/} assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options)) |