ruby-changes:62268
From: nagachika <ko1@a...>
Date: Sun, 19 Jul 2020 11:33:17 +0900 (JST)
Subject: [ruby-changes:62268] ad15fd03e9 (ruby_2_7): merge revision(s) 26c179d7e7e7ae0eb21050659c3e8778358230ab: [Backport #17026]
https://git.ruby-lang.org/ruby.git/commit/?id=ad15fd03e9 From ad15fd03e915272bdf4b3a8403722b397e3afcf8 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sun, 19 Jul 2020 11:32:59 +0900 Subject: merge revision(s) 26c179d7e7e7ae0eb21050659c3e8778358230ab: [Backport #17026] Check argument to ObjectSpace._id2ref Ensure that the argument is an Integer or implicitly convert to, before dereferencing as a Bignum. Addressed a regression in b99833baec2. Reported by u75615 at https://hackerone.com/reports/898614 diff --git a/gc.c b/gc.c index 0c007df..4700234 100644 --- a/gc.c +++ b/gc.c @@ -3648,6 +3648,7 @@ id2ref(VALUE objid) https://github.com/ruby/ruby/blob/trunk/gc.c#L3648 VALUE orig; void *p0; + objid = rb_to_int(objid); if (FIXNUM_P(objid) || rb_big_size(objid) <= SIZEOF_VOIDP) { ptr = NUM2PTR(objid); if (ptr == Qtrue) return Qtrue; diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index 243e9f6..02c20aa 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -55,6 +55,16 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_objectspace.rb#L55 EOS end + def test_id2ref_invalid_argument + msg = /no implicit conversion/ + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(nil)} + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(false)} + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(true)} + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(:a)} + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref("0")} + assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(Object.new)} + end + def test_count_objects h = {} ObjectSpace.count_objects(h) diff --git a/version.h b/version.h index 52d8de1..c0937dc 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 93 +#define RUBY_PATCHLEVEL 94 #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 19 #include "ruby/version.h" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/