Prevent an address violation parsing corrupt DWARF information by fixing the test...
authorNick Clifton <nickc@redhat.com>
Fri, 1 Sep 2017 10:20:51 +0000 (11:20 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 1 Sep 2017 10:20:51 +0000 (11:20 +0100)
PR 22059
* dwarf2.c (decode_line_info): Fix test for an overlong line info
structure.

bfd/ChangeLog
bfd/dwarf2.c

index e0dd88fafada7f775dfcd65ba9fd4235b970c092..8c6e8b14f754a11283039d8f5b39945175ec5a03 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-01  Nick Clifton  <nickc@redhat.com>
+
+       PR 22059
+       * dwarf2.c (decode_line_info): Fix test for an overlong line info
+       structure.
+
 2017-09-01  Nick Clifton  <nickc@redhat.com>
 
        PR 22058
index 40a187a1a43932ecb1b9d1ea99473ebf6f7dee02..856c963985cdf03568b2736dd6a3fd30d86e19f4 100644 (file)
@@ -2096,12 +2096,12 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
       offset_size = 8;
     }
 
-  if (lh.total_length > stash->dwarf_line_size)
+  if (unit->line_offset + lh.total_length > stash->dwarf_line_size)
     {
       _bfd_error_handler
        /* xgettext: c-format */
-       (_("Dwarf Error: Line info data is bigger (%#Lx) than the section (%#Lx)"),
-        lh.total_length, stash->dwarf_line_size);
+       (_("Dwarf Error: Line info data is bigger (%#Lx) than the space remaining in the section (%#Lx)"),
+        lh.total_length, stash->dwarf_line_size - unit->line_offset);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
     }