PR binutils/22875: Visium/ELF: Prevent an out-of-bounds howto table access
[deliverable/binutils-gdb.git] / bfd / elf32-d30v.c
index 984b4c4fb582ef4e2b489ee07a68fbac426eece7..7620a737ff0404965b3f22c79ac162b5dc01f629 100644 (file)
@@ -508,7 +508,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an D30V ELF reloc (type REL).  */
 
-static void
+static bfd_boolean
 d30v_info_to_howto_rel (bfd *abfd,
                        arelent *cache_ptr,
                        Elf_Internal_Rela *dst)
@@ -521,14 +521,16 @@ d30v_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
                          abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_d30v_howto_table[r_type];
+  return TRUE;
 }
 
 /* Set the howto pointer for an D30V ELF reloc (type RELA).  */
 
-static void
+static bfd_boolean
 d30v_info_to_howto_rela (bfd *abfd,
                         arelent *cache_ptr,
                         Elf_Internal_Rela *dst)
@@ -541,9 +543,11 @@ d30v_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
                          abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_d30v_howto_table[r_type];
+  return TRUE;
 }
 
 #define ELF_ARCH               bfd_arch_d30v
This page took 0.024047 seconds and 4 git commands to generate.