diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-17 23:52:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-17 23:52:48 +0000 |
commit | 4f46b1777bfb55f04f0c89134b41e91c5cdef9b2 (patch) | |
tree | e9e5429892ff1dfe7a135b3d22dceca163f65f7c /test/stringio | |
parent | b8228e4cd81b40708754236c43d15fa9dfc0647c (diff) | |
download | ruby-4f46b1777bfb55f04f0c89134b41e91c5cdef9b2.tar.gz |
stringio.c: fix index overflow
* ext/stringio/stringio.c (strio_getline): fix pointer index
overflow. reported by Guido Vranken <guido AT guidovranken.nl>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/stringio')
-rw-r--r-- | test/stringio/test_stringio.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index bf3a9eeb1b..ce84800d4b 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -680,4 +680,16 @@ class TestStringIO < Test::Unit::TestCase StringIO.new {} end end + + def test_overflow + limit = (1 << (RbConfig::SIZEOF["size_t"]*8-1)) - 0x10 + assert_separately(%w[-rstringio], "#{<<-"begin;"}\n#{<<-"end;"}") + begin; + limit = #{limit} + x = ("a"*0x100000) + s = StringIO.new(x) + s.gets("xxx", limit) + assert_equal(0x100000, s.pos) + end; + end end |