summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-enumerator/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-19 20:53:32 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-09-19 22:01:59 +0900
commitc09d250ca148c0efc0167d55885bd20da87b43f7 (patch)
treedd1ed14792a5bf45a79d44167556b4206c9698d8 /mrbgems/mruby-enumerator/mrblib
parent8b43754644660c9dcdc6b8b18a1917f01e77479e (diff)
downloadmruby-c09d250ca148c0efc0167d55885bd20da87b43f7.tar.gz
mruby-c09d250ca148c0efc0167d55885bd20da87b43f7.zip
Remove implicit conversion using `to_int` method.
The ISO standard does not include implicit type conversion using `to_int`. This implicit conversion often causes vulnerability. There will be no more attacks like #4120. In addition, we have added internal convenience method `__to_int` which does type check and conversion (from floats).
Diffstat (limited to 'mrbgems/mruby-enumerator/mrblib')
-rw-r--r--mrbgems/mruby-enumerator/mrblib/enumerator.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
index 7ca1d5eb6..22856a91b 100644
--- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb
+++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -157,12 +157,10 @@ class Enumerator
def with_index(offset=0, &block)
return to_enum :with_index, offset unless block
- offset = if offset.nil?
- 0
- elsif offset.respond_to?(:to_int)
- offset.to_int
+ if offset.nil?
+ offset = 0
else
- raise TypeError, "no implicit conversion of #{offset.class} into Integer"
+ offset = offset.__to_int
end
n = offset - 1