buffer overflow in print_symname
authorAlan Modra <amodra@gmail.com>
Wed, 19 Apr 2023 12:23:18 +0000 (21:53 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 19 Apr 2023 23:33:53 +0000 (09:03 +0930)
* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Zero terminate
string sections.

bfd/ecoff.c

index fb6fcade9134e2f3dd5f849c7e0c798a02f29eb9..676b8d840176501169f72ed63fcc3e462dc98d17 100644 (file)
@@ -599,6 +599,12 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
   FIX (cbExtOffset, iextMax, external_ext, void *);
 #undef FIX
 
+  /* Ensure string sections are zero terminated.  */
+  if (debug->ss)
+    debug->ss[internal_symhdr->issMax - 1] = 0;
+  if (debug->ssext)
+    debug->ssext[internal_symhdr->issExtMax - 1] = 0;
+
   /* I don't want to always swap all the data, because it will just
      waste time and most programs will never look at it.  The only
      time the linker needs most of the debugging information swapped