diff options
author | Alan Modra <amodra@gmail.com> | 2022-08-06 19:54:46 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-08-06 19:59:02 +0930 |
commit | 45c8663b92cc29eb330dbcc6c500fa798f05ae37 (patch) | |
tree | 877469fc158cb740d356c70dc536d29e19f43997 | |
parent | 431d48ef288983b62df2afb435dc8c6101a34cf8 (diff) | |
download | gdb-45c8663b92cc29eb330dbcc6c500fa798f05ae37.zip gdb-45c8663b92cc29eb330dbcc6c500fa798f05ae37.tar.gz gdb-45c8663b92cc29eb330dbcc6c500fa798f05ae37.tar.bz2 |
asan: heap buffer overflow in _bfd_error_handler
On coff_slurp_symbol_table printing "unrecognized storage class"
for a symbol error. If the symbol name is the last string in its
section and not terminated, we run off the end of the buffer.
* coffgen.c (build_debug_section): Terminate the section with
an extra 0.
-rw-r--r-- | bfd/coffgen.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 4d2b82e..90fba3b 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -1539,9 +1539,10 @@ build_debug_section (bfd *abfd, asection ** sect_return) return NULL; sec_size = sect->size; - debug_section = (char *) _bfd_alloc_and_read (abfd, sec_size, sec_size); + debug_section = (char *) _bfd_alloc_and_read (abfd, sec_size + 1, sec_size); if (debug_section == NULL) return NULL; + debug_section[sec_size] = 0; if (bfd_seek (abfd, position, SEEK_SET) != 0) return NULL; |