[binutils-gdb/binutils-2_29-branch] PR22067, x86 check_relocs invalid read

Alan Modra amodra@sourceware.org
Sun Sep 3 23:08:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4b2b2eec571dd6b78368661c3084df0ce6d9fff2

commit 4b2b2eec571dd6b78368661c3084df0ce6d9fff2
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Sep 4 08:35:21 2017 +0930

    PR22067, x86 check_relocs invalid read
    
    	PR 22067
    	* elf32-i386.c (elf_i386_hash_table): Check is_elf_hash_table first.
    	* elf64-x86-64.c (elf_x86_64_hash_table): Likewise.

Diff:
---
 bfd/ChangeLog      | 6 ++++++
 bfd/elf32-i386.c   | 3 ++-
 bfd/elf64-x86-64.c | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b5f1204..9df9bc6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-04  Alan Modra  <amodra@gmail.com>
+
+	PR 22067
+	* elf32-i386.c (elf_i386_hash_table): Check is_elf_hash_table first.
+	* elf64-x86-64.c (elf_x86_64_hash_table): Likewise.
+
 2017-09-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/22064
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index a2866c5..c123f12 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1113,7 +1113,8 @@ struct elf_i386_link_hash_table
 /* Get the i386 ELF linker hash table from a link_info structure.  */
 
 #define elf_i386_hash_table(p) \
-  (elf_hash_table_id  ((struct elf_link_hash_table *) ((p)->hash)) \
+  (is_elf_hash_table ((p)->hash) \
+   && elf_hash_table_id  ((struct elf_link_hash_table *) ((p)->hash))	\
   == I386_ELF_DATA ? ((struct elf_i386_link_hash_table *) ((p)->hash)) : NULL)
 
 #define elf_i386_compute_jump_table_size(htab) \
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 59926b6..c59b8c0 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1227,7 +1227,8 @@ struct elf_x86_64_link_hash_table
 /* Get the x86-64 ELF linker hash table from a link_info structure.  */
 
 #define elf_x86_64_hash_table(p) \
-  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+  (is_elf_hash_table ((p)->hash) \
+   && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash))	\
   == X86_64_ELF_DATA ? ((struct elf_x86_64_link_hash_table *) ((p)->hash)) : NULL)
 
 #define elf_x86_64_compute_jump_table_size(htab) \



More information about the Binutils-cvs mailing list