* dwarf2read.c (dwarf_decode_lines): Detect address size mismatches.
authorDaniel Jacobowitz <drow@false.org>
Tue, 17 Jul 2007 12:46:35 +0000 (12:46 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 17 Jul 2007 12:46:35 +0000 (12:46 +0000)
gdb/ChangeLog
gdb/dwarf2read.c

index eb4892531a1824eb5c7c66230c19b34dbfa11135..0e2f5ff132b72816bfbbb0afb8df5b4e4971619f 100644 (file)
@@ -1,3 +1,7 @@
+2007-07-17  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * dwarf2read.c (dwarf_decode_lines): Detect address size mismatches.
+
 2007-07-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * i386-linux-nat.c (fetch_regs): Work around gcc 3.4 alias
index 32d6f159f774badce866a8ac187a66d91c9ee43c..c12e3da62798e53f7c0de220b39dd54af01d1ea1 100644 (file)
@@ -6668,9 +6668,9 @@ static void
 dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                    struct dwarf2_cu *cu, struct partial_symtab *pst)
 {
-  gdb_byte *line_ptr;
+  gdb_byte *line_ptr, *extended_end;
   gdb_byte *line_end;
-  unsigned int bytes_read;
+  unsigned int bytes_read, extended_len;
   unsigned char op_code, extended_op, adj_opcode;
   CORE_ADDR baseaddr;
   struct objfile *objfile = cu->objfile;
@@ -6745,8 +6745,9 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
          else switch (op_code)
            {
            case DW_LNS_extended_op:
-             read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+             extended_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
              line_ptr += bytes_read;
+             extended_end = line_ptr + extended_len;
              extended_op = read_1_byte (abfd, line_ptr);
              line_ptr += 1;
              switch (extended_op)
@@ -6792,6 +6793,15 @@ dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
                             _("mangled .debug_line section"));
                  return;
                }
+             /* Make sure that we parsed the extended op correctly.  If e.g.
+                we expected a different address size than the producer used,
+                we may have read the wrong number of bytes.  */
+             if (line_ptr != extended_end)
+               {
+                 complaint (&symfile_complaints,
+                            _("mangled .debug_line section"));
+                 return;
+               }
              break;
            case DW_LNS_copy:
              if (lh->num_file_names < file)