diff options
author | Greg Clayton <gclayton@apple.com> | 2011-10-31 20:50:40 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-10-31 20:50:40 +0000 |
commit | 4f8e86979a7ffe0e02c2c9afacdc75c83f52ee88 (patch) | |
tree | a21ff6d73ca5b1c3b6a1fb65f83b3c441a9db518 | |
parent | ced5e7b99b0b682bd1c42798b6dff198915a45c7 (diff) | |
download | bcm5719-llvm-4f8e86979a7ffe0e02c2c9afacdc75c83f52ee88.tar.gz bcm5719-llvm-4f8e86979a7ffe0e02c2c9afacdc75c83f52ee88.zip |
<rdar://problem/10368163>
Fixed an issue where if a mach-o symbol table was corrupt and had a string
table offset that is invalid, we could crash. We now properly check the string
table offset and ignore any symbols with invalid strings.
llvm-svn: 143362
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 9a5ce34137a..679e2b2c312 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -772,8 +772,7 @@ ObjectFileMachO::ParseSymtab (bool minimize) DataBufferSP strtab_data_sp(m_file.ReadFileContents(m_offset + symtab_load_command.stroff, symtab_load_command.strsize)); const char *strtab_data = (const char *)strtab_data_sp->GetBytes(); -// DataExtractor symtab_data(symtab_data_sp, endian, addr_size); -// DataExtractor strtab_data(strtab_data_sp, endian, addr_size); + const size_t strtab_data_len = strtab_data_sp->GetByteSize(); static ConstString g_segment_name_TEXT ("__TEXT"); static ConstString g_segment_name_DATA ("__DATA"); @@ -840,7 +839,21 @@ ObjectFileMachO::ParseSymtab (bool minimize) } SymbolType type = eSymbolTypeInvalid; + if (nlist.n_strx >= strtab_data_len) + { + // No symbol should be NULL, even the symbols with no + // string values should have an offset zero which points + // to an empty C-string + fprintf (stderr, + "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n", + nlist_idx, + nlist.n_strx, + m_module->GetFileSpec().GetDirectory().GetCString(), + m_module->GetFileSpec().GetFilename().GetCString()); + continue; + } const char* symbol_name = &strtab_data[nlist.n_strx]; + if (symbol_name[0] == '\0') symbol_name = NULL; Section* symbol_section = NULL; |