1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 62992:

pack.c: fix underflow

	* pack.c (pack_unpack_internal): get rid of underflow.
	  https://hackerone.com/reports/298246

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-03-28 14:38:39 +00:00
parent 47165eed26
commit 4cd92d7b13
4 changed files with 12 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Wed Mar 28 23:37:18 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
pack.c: fix underflow
* pack.c (pack_unpack_internal): get rid of underflow.
https://hackerone.com/reports/298246
Wed Mar 28 23:35:28 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
unixsocket.c: check NUL bytes

2
pack.c
View file

@ -1203,7 +1203,7 @@ pack_unpack(VALUE str, VALUE fmt)
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");
}
}

View file

@ -480,6 +480,9 @@ class TestPack < Test::Unit::TestCase
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

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.10"
#define RUBY_RELEASE_DATE "2018-03-28"
#define RUBY_PATCHLEVEL 485
#define RUBY_PATCHLEVEL 486
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3