ruby-changes:50795
From: nagachika <ko1@a...>
Date: Wed, 28 Mar 2018 20:45:02 +0900 (JST)
Subject: [ruby-changes:50795] nagachika:r63001 (ruby_2_4): merge revision(s) 62992:
nagachika 2018-03-28 20:44:55 +0900 (Wed, 28 Mar 2018) New Revision: 63001 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63001 Log: merge revision(s) 62992: pack.c: fix underflow * pack.c (pack_unpack_internal): get rid of underflow. https://hackerone.com/reports/298246 Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/pack.c branches/ruby_2_4/test/ruby/test_pack.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 63000) +++ ruby_2_4/version.h (revision 63001) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2018-03-28" -#define RUBY_PATCHLEVEL 291 +#define RUBY_PATCHLEVEL 292 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/test/ruby/test_pack.rb =================================================================== --- ruby_2_4/test/ruby/test_pack.rb (revision 63000) +++ ruby_2_4/test/ruby/test_pack.rb (revision 63001) @@ -548,6 +548,9 @@ class TestPack < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_pack.rb#L548 assert_equal([1, 2], "\x01\x00\x00\x02".unpack("C@3C")) assert_equal([nil], "\x00".unpack("@1C")) # is it OK? assert_raise(ArgumentError) { "\x00".unpack("@2C") } + + pos = (1 << [nil].pack("p").bytesize * 8) - 100 # -100 + assert_raise(RangeError) {"0123456789".unpack("@#{pos}C10")} end def test_pack_unpack_percent Index: ruby_2_4/pack.c =================================================================== --- ruby_2_4/pack.c (revision 63000) +++ ruby_2_4/pack.c (revision 63001) @@ -1138,7 +1138,7 @@ pack_unpack_internal(VALUE str, VALUE fm https://github.com/ruby/ruby/blob/trunk/ruby_2_4/pack.c#L1138 else if (ISDIGIT(*p)) { errno = 0; len = STRTOUL(p, (char**)&p, 10); - if (errno) { + if (len < 0 || errno) { rb_raise(rb_eRangeError, "pack length too big"); } } Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 63000) +++ ruby_2_4 (revision 63001) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62992 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/