]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Prevent illegal memory accesses when attempting to read excessively large COFF line...
authorNick Clifton <nickc@redhat.com>
Wed, 1 Nov 2017 15:21:46 +0000 (15:21 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 1 Nov 2017 15:21:46 +0000 (15:21 +0000)
PR 22376
* coffcode.h (coff_slurp_line_table): Check for an excessively
large line number count.

bfd/ChangeLog
bfd/coffcode.h

index 60fbc9c8e48425243774c8044b206edad29766cc..35308ab8343e9813e03ab0a5290f6b0a4527b183 100644 (file)
@@ -1,3 +1,9 @@
+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
index 21308de8c31351da3694b2790b7b99e54b77188c..6da0afa26d29dd27dc1fc741467205c00fbd36e3 100644 (file)
@@ -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)