This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Prevent illegal memory accesses when attempting to read excessively large COFF line number tables.


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

commit a67d66eb97e7613a38ffe6622d837303b3ecd31d
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Nov 1 15:21:46 2017 +0000

    Prevent illegal memory accesses when attempting to read excessively large COFF line number tables.
    
    	PR 22376
    	* coffcode.h (coff_slurp_line_table): Check for an excessively
    	large line number count.

Diff:
---
 bfd/ChangeLog  | 6 ++++++
 bfd/coffcode.h | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 60fbc9c..35308ab 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
 2017-11-01  Nick Clifton  <nickc@redhat.com>
 
+	PR 22376
+	* coffcode.h (coff_slurp_line_table): Check for an excessively
+	large line number count.
+
+2017-11-01  Nick Clifton  <nickc@redhat.com>
+
 	PR 22373
 	* peicode.h (pe_bfd_read_buildid): Revise check for invalid size
 	and offset in light of further possible bogus values.
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 21308de..6da0afa 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -4578,6 +4578,14 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
 
   BFD_ASSERT (asect->lineno == NULL);
 
+  if (asect->lineno_count > asect->size)
+    {
+      _bfd_error_handler
+	(_("%B: warning: line number count (%#lx) exceeds section size (%#lx)"),
+	 abfd, (unsigned long) asect->lineno_count, (unsigned long) asect->size);
+      return FALSE;
+    }
+
   amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent);
   lineno_cache = (alent *) bfd_alloc (abfd, amt);
   if (lineno_cache == NULL)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]