public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] asan: heap buffer overflow in _bfd_error_handler
@ 2022-08-06 10:32 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-08-06 10:32 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=45c8663b92cc29eb330dbcc6c500fa798f05ae37

commit 45c8663b92cc29eb330dbcc6c500fa798f05ae37
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 6 19:54:46 2022 +0930

    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.

Diff:
---
 bfd/coffgen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 4d2b82e4a6f..90fba3b8554 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-06 10:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-06 10:32 [binutils-gdb] asan: heap buffer overflow in _bfd_error_handler Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).