summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-27 23:18:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-27 23:18:52 +0000
commit9ae4c2d59098ce6158385dda2539d2b36a03c090 (patch)
tree305ab7c3b2fff3a65b3f2ea3f40392f3c1835dd6 /test
parentd1e2d6a9c52749912e8239d51b6beb5c6d9de943 (diff)
sprintf.c: fix buffer overflow
* 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/trunk@54304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_sprintf.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 501930a1e5..5732cecbf9 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -177,6 +177,10 @@ class TestSprintf < Test::Unit::TestCase
assert_equal("x"*10+" 1.0", sprintf("x"*10+"%8.1f", 1r), bug11766)
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))