Re: [PATCH 02/13] gdb/dwarf: fix bound check in read_rnglist_index

Zoran Zaric via Gdb-patches
2021-01-28T15:23:09Z

> From: Simon Marchi <simon.marchi@efficios.com>
>
> I think this check in read_rnglist_index is wrong:
>
> /* Validate that reading won't go beyond the end of the section. */
> if (start_offset + cu->header.offset_size > rnglist_base + section->size)
> error (_("Reading DW_FORM_rnglistx index beyond end of"
> ".debug_rnglists section [in module %s]"),
> objfile_name (objfile));
>
> The addition `rnglist_base + section->size` doesn't make sense.
> rnglist_base is an offset into `section`, so it doesn't make sense to
> add it to `section`'s size. `start_offset` also is an offset into
> `section`, so we should just compare it to just `section->size`.

Completely agree with this change.