[PATCH 2/6] PR binutils/22875: FRV/ELF: Prevent an out-of-bounds howto table access

Alan Modra amodra@gmail.com
Fri Mar 30 12:37:00 GMT 2018


On Thu, Mar 29, 2018 at 06:32:29PM +0100, Maciej W. Rozycki wrote:
> Prevent an out-of-bounds `elf32_frv_howto_table' table access in 
> `frv_info_to_howto_rela' and redefine R_FRV_max to hold the number of 
> entries in the contiguous regular FRV relocation range defined and 
> described in the table, keeping the definitions of R_FRV_GNU_VTINHERIT 
> and R_FRV_GNU_VTENTRY as outliers.
> 
> 	include/
> 	* elf/frv.h (R_FRV_max): Redefine as `R_FRV_TLSMOFF + 1'.

I think it would be better to leave R_FRV_max unchanged and change the
single use of R_FRV_max to "sizeof (elf32_frv_howto_table)
/ sizeof (elf32_frv_howto_table[0])".  Or include libiberty.h and use
ARRAY_SIZE.

That way the next time I look at include/elf/frv.h I won't wonder why
R_FRV_max is defined rather oddly, questioning why it isn't the
highest defined reloc plus one, and when looking at elf32-frv.c I
won't need to check that R_FRV_max is correct.

The same comment applies to the other R_*_max patches.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list