[binutils-gdb] asan: buffer overflow in mmo_get_symbols

Alan Modra amodra@sourceware.org
Fri Dec 17 06:25:46 GMT 2021


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

commit 00d44f7f2f513c56a784a6d418833bb3da8a188f
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Dec 17 12:41:28 2021 +1030

    asan: buffer overflow in mmo_get_symbols
    
            * mmo.c (mmo_get_symbols): Error on symbol name exceeding max length.

Diff:
---
 bfd/mmo.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bfd/mmo.c b/bfd/mmo.c
index 2ee386662a4..d80cb06f746 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -1411,6 +1411,16 @@ SUBSECTION
 	    c = c2;
 	}
 
+      if (abfd->tdata.mmo_data->symbol_position
+	  >= abfd->tdata.mmo_data->max_symbol_length)
+	{
+	  _bfd_error_handler
+	    /* xgettext:c-format */
+	    (_("%pB: symbol name exceeds given max length of %d"),
+	     abfd, abfd->tdata.mmo_data->max_symbol_length);
+	  abfd->tdata.mmo_data->have_error = true;
+	  return false;
+	}
       abfd->tdata.mmo_data->lop_stab_symbol[abfd->tdata.mmo_data->symbol_position++] = c;
       abfd->tdata.mmo_data->lop_stab_symbol[abfd->tdata.mmo_data->symbol_position] = 0;


More information about the Binutils-cvs mailing list