Project

General

Profile

Actions

Bug #22325

open

out of bounds read in array

Bug #22325: out of bounds read in array

Added by danielchong (Daniel Chong) 4 days ago. Updated 4 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:126743]

Description

Hi, an OOB read seems possible in array

class bad < Numeric
  def initialize(v); @v = v; end
  def val; @v; end
  def <=>(o); @v <=> (o.is_a?(bad) ? o.val : o); end
  def to_int; $a.clear; @v; end
  def to_i; @v; end
  def coerce(o); [o, @v]; end
end
$a = (1..3000).to_a
seq = Range.new(bad.new(2900), bad.new(2950)).step(2)  

asan output (truncated):

ERROR: AddressSanitizer: heap-buffer-overflow ... READ of size 8 ...
    #0 ary_make_partial_step  array.c:1303
    #1 rb_ary_aref1           array.c:1947
    #2 vm_opt_aref            vm_insnhelper.c:7224
SUMMARY: AddressSanitizer: heap-buffer-overflow array.c:1303:9 in ary_make_partial_step
Actions

Also available in: PDF Atom