From: Maciej W. Rozycki Date: Wed, 4 Apr 2018 01:00:48 +0000 (+0100) Subject: PR binutils/22875: FRV/ELF: Prevent an out-of-bounds howto table access X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f428698edfd845a21639f5145cba3772eb92abc2;p=binutils-gdb.git PR binutils/22875: FRV/ELF: Prevent an out-of-bounds howto table access Prevent an out-of-bounds `elf32_frv_howto_table' table access in `frv_info_to_howto_rela' by using the size of the table rather than R_FRV_max to determine the number of entries in the contiguous regular FRV relocation range defined and described in the table. bfd/ * elf32-frv.c (frv_info_to_howto_rela): Correct the range check for `elf32_frv_howto_table' table access. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c5e0a91ab75..072ad98a774 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2018-04-04 Maciej W. Rozycki + + * elf32-frv.c (frv_info_to_howto_rela): Correct the range check + for `elf32_frv_howto_table' table access. + 2018-04-04 Maciej W. Rozycki * elf32-mips.c (mips_elf32_rtype_to_howto): Also return diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index 7831aff806b..fc0bdcde7ea 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -25,6 +25,7 @@ #include "elf/frv.h" #include "dwarf2.h" #include "hashtab.h" +#include "libiberty.h" /* Forward declarations. */ @@ -2551,7 +2552,7 @@ frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, break; default: - if (r_type >= (unsigned int) R_FRV_max) + if (r_type >= ARRAY_SIZE (elf32_frv_howto_table)) { /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),