[PATCH] PR28415: Xtensa stack-buffer-overflow in objdump at disassemble_bytes

Guillermo E. Martinez guillermo.e.martinez@oracle.com
Thu Oct 7 15:42:57 GMT 2021


 Hello,

 This patch fix the issue repoted by Irfan Ariq,

    https://sourceware.org/bugzilla/show_bug.cgi?id=28415

 Plase let me know your comments. Thanks in advance

 Kind Regards,
 Guillermo

  * elf32-xtensa.c (xtensa_read_table_entries): table_data variable is
    not taking care of the return value for retrieve_contents assuming
    valid bytes for section read, further used in bfd_get_32.
---
 bfd/elf32-xtensa.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index e5bfbb2f509..98039757c22 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -910,7 +910,14 @@ xtensa_read_table_entries (bfd *abfd,
     table_entry_size -= 4;
 
   num_records = table_size / table_entry_size;
+
   table_data = retrieve_contents (abfd, table_section, true);
+  if (table_data == 0)
+    {
+      *table_p = NULL;
+      return 0;
+    }
+
   blocks = (property_table_entry *)
     bfd_malloc (num_records * sizeof (property_table_entry));
   block_count = 0;
-- 
2.33.0



More information about the Binutils mailing list