aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-10-09 16:53:27 +0100
committerNick Clifton <nickc@redhat.com>2023-10-09 16:53:27 +0100
commitcb0f1baf44a4de4506283502df68cad3b7780e1d (patch)
treed81c340e3d7e469aa6800269e61f0c9da9e3dfed
parente7c3fa04b6c54aae88675a7dcd9c76b322ec2171 (diff)
downloadgdb-cb0f1baf44a4de4506283502df68cad3b7780e1d.zip
gdb-cb0f1baf44a4de4506283502df68cad3b7780e1d.tar.gz
gdb-cb0f1baf44a4de4506283502df68cad3b7780e1d.tar.bz2
Fix: Null pointer dereference in elf32-i386.c
PR 30950 * elf32-i386.c (elf_i386_convert_load_reloc): Check for elf_x86_hash_table returning a NULL pointer.
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf32-i386.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index da28772..2731d85 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7e6823b..abfba40 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -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;