Fix: Null pointer dereference in elf32-i386.c
authorNick Clifton <nickc@redhat.com>
Mon, 9 Oct 2023 15:53:27 +0000 (16:53 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 9 Oct 2023 15:53:27 +0000 (16:53 +0100)
  PR 30950
  * elf32-i386.c (elf_i386_convert_load_reloc): Check for elf_x86_hash_table returning a NULL pointer.

bfd/ChangeLog
bfd/elf32-i386.c

index da287723935af9c69581cc61c70cb146ca361b91..2731d85db5c2a13fe98603547b38574ab4c77090 100644 (file)
@@ -1,5 +1,9 @@
 2023-10-09  Nick Clifton  <nickc@redhat.com>
 
+       PR 30950
+       * elf32-i386.c (elf_i386_convert_load_reloc): Check for
+       elf_x86_hash_table returning a NULL pointer.
+
        PR 30949
        * elflink.c (elf_gc_mark_debug_section): Check for
        bfd_section_from_elf_index returning a NULL pointer.
index 7e6823b40f4ef9d90a0070bebe62522b43754ec7..abfba406a81d117ea0fba687d224a732d6597f9b 100644 (file)
@@ -1241,6 +1241,12 @@ elf_i386_convert_load_reloc (bfd *abfd, Elf_Internal_Shdr *symtab_hdr,
     return true;
 
   htab = elf_x86_hash_table (link_info, I386_ELF_DATA);
+  if (htab == NULL || ! is_x86_elf (abfd, htab))
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return false;
+    }
+
   is_pic = bfd_link_pic (link_info);
 
   r_type = *r_type_p;