PR28415, invalid read in xtensa_read_table_entries
authorGuillermo E. Martinez <guillermo.e.martinez@oracle.com>
Thu, 7 Oct 2021 05:49:13 +0000 (16:19 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 9 Oct 2021 03:32:07 +0000 (14:02 +1030)
PR 28415
PR 28416
* elf32-xtensa.c (xtensa_read_table_entries): Handle error
return from retrieve_contents.

bfd/elf32-xtensa.c

index e5bfbb2f509994f946cdc9c0b6621b1797bccdaa..dc5b2d30cbef0a161cfa73458fc248239282bef1 100644 (file)
@@ -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 == NULL)
+    {
+      *table_p = NULL;
+      return 0;
+    }
+
   blocks = (property_table_entry *)
     bfd_malloc (num_records * sizeof (property_table_entry));
   block_count = 0;