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] PR22200, DWARF5 .debug_line sanity check


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

commit c361faae8d964db951b7100cada4dcdc983df1bf
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Sep 25 19:03:46 2017 +0930

    PR22200, DWARF5 .debug_line sanity check
    
    The format_count entry can't be zero unless the count is also zero.
    
    	PR 22200
    	* dwarf2.c (read_formatted_entries): Error on format_count zero.

Diff:
---
 bfd/ChangeLog | 5 +++++
 bfd/dwarf2.c  | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 92a6c27..adbc014 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-25  Alan Modra  <amodra@gmail.com>
+
+	PR 22200
+	* dwarf2.c (read_formatted_entries): Error on format_count zero.
+
 2017-09-24  Alan Modra  <amodra@gmail.com>
 
 	PR 22197
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 1566cd8..8abb3f0 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1933,6 +1933,13 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp,
 
   data_count = _bfd_safe_read_leb128 (abfd, buf, &bytes_read, FALSE, buf_end);
   buf += bytes_read;
+  if (format_count == 0 && data_count != 0)
+    {
+      _bfd_error_handler (_("Dwarf Error: Zero format count."));
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
   for (datai = 0; datai < data_count; datai++)
     {
       bfd_byte *format = format_header_data;


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