summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-19 20:53:32 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-11-19 11:28:51 +0900
commitafca99a40b8a3415b3a9a0e8fc41c93ddcbb11d8 (patch)
tree6ecbeb3c8a562ce64713ccd4d2d6b1d12e6b5fa2 /mrblib
parent426c1f9e0b77a27d5384ccdee7f7a49eef0e2ed0 (diff)
downloadmruby-afca99a40b8a3415b3a9a0e8fc41c93ddcbb11d8.tar.gz
mruby-afca99a40b8a3415b3a9a0e8fc41c93ddcbb11d8.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 'mrblib')
-rw-r--r--mrblib/array.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb
index 53d880660..a677b2a1f 100644
--- a/mrblib/array.rb
+++ b/mrblib/array.rb
@@ -66,7 +66,7 @@ class Array
#
# ISO 15.2.12.5.15
def initialize(size=0, obj=nil, &block)
- raise TypeError, "expected Integer for 1st argument" unless size.kind_of? Integral
+ size = size.__to_int
raise ArgumentError, "negative array size" if size < 0
self.clear