summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-04-19 21:53:18 +0930
committerAlan Modra <amodra@gmail.com>2023-04-20 09:03:53 +0930
commit685b44ee816c6e508d282ae3766f2441b5ae9334 (patch)
tree7c865a0dc9d1f759f9d801f04cbd8e47de473f49
parent3cae258044e8d45895ef9b0cce5d8fc7b9c3dd1d (diff)
downloadbinutils-gdb-685b44ee816c6e508d282ae3766f2441b5ae9334.tar.gz
buffer overflow in print_symname
* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Zero terminate string sections.
-rw-r--r--bfd/ecoff.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index fb6fcade913..676b8d84017 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -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