diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-01 06:39:17 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-04-12 21:30:49 +0900 |
commit | d0a822eec524522d81ffc7da2bb1baf906b0318a (patch) | |
tree | 3255a74577a649e963eb7a2dc244db6cfe7a2ad5 /test | |
parent | cf2bbcfff2985c116552967c7c4522f4630f2d18 (diff) |
Fix dtoa buffer overrun
https://hackerone.com/reports/1248108
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5794
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_float.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 4be2cfeeda..57a46fce92 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -171,6 +171,24 @@ class TestFloat < Test::Unit::TestCase assert_raise(ArgumentError, n += z + "A") {Float(n)} assert_raise(ArgumentError, n += z + ".0") {Float(n)} end + + x = nil + 2000.times do + x = Float("0x"+"0"*30) + break unless x == 0.0 + end + assert_equal(0.0, x, ->{"%a" % x}) + x = nil + 2000.times do + begin + x = Float("0x1."+"0"*270) + rescue ArgumentError => e + raise unless /"0x1\.0{270}"/ =~ e.message + else + break + end + end + assert_nil(x, ->{"%a" % x}) end def test_divmod |