]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make sure we have all the DWARF2 sections before trying to decode
authorTom Hughes <tom@compton.nu>
Tue, 4 Oct 2005 16:54:54 +0000 (16:54 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 4 Oct 2005 16:54:54 +0000 (16:54 +0000)
any DWARF2 debug information. All make sure we don't fall over if
the .debug_info is less than four bytes long. Fixed bug 113642.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4856

coregrind/m_debuginfo/dwarf.c
coregrind/m_debuginfo/symtab.c

index fc42b36462713b941aa51af1da9c12ef92c34ff9..54ed384d76c86a20b8561bd7590f4af3cb749b15 100644 (file)
@@ -916,6 +916,12 @@ void ML_(read_debuginfo_dwarf2)
    UChar*   end = debuginfo + debug_info_sz;
    UInt     blklen;
 
+   /* Make sure we at least have a header for the first block */
+   if (debug_info_sz < 4) {
+     ML_(symerr)( "Last block truncated in .debug_info; ignoring" );
+      return;
+   }
+
    /* Iterate on all the blocks we find in .debug_info */
    for ( block = debuginfo; block < end - 4; block += blklen + 4 ) {
 
index 281418af5cdea0f243ff962bef01cd93b17b28d8..e9b804a54cbd2d000b3039ee437fa6380e01b177 100644 (file)
@@ -1745,7 +1745,7 @@ Bool read_lib_symbols ( SegInfo* si )
                                          stabstr, stabstr_sz );
       }
 #     endif
-      if (debug_line) {
+      if (debug_info && debug_abbv && debug_line && debug_str) {
          ML_(read_debuginfo_dwarf2) ( si, 
                                       debug_info,   debug_info_sz,
                                       debug_abbv,