Relates :
|
There's a bug in ElfSymbolTable::lookup - when it fails to find a symbol, it returns true (false should be returned). bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset, ElfFuncDescTable* funcDescTable) { .... return true; // <-- huh? } As a result the caller, ElfFile::decode, would be operating on an invalid string_table_index, which will cause m_status = NullDecoder::file_invalid, which will make all future calls to ElfFile::decode fail. bool ElfFile::decode(address addr, char* buf, int buflen, int* offset) { // something already went wrong, just give up if (NullDecoder::is_error(m_status)) { return false; } ElfSymbolTable* symbol_table = m_symbol_tables; int string_table_index; int pos_in_string_table; int off = INT_MAX; bool found_symbol = false; while (symbol_table != NULL) { if (symbol_table->lookup(addr, &string_table_index, &pos_in_string_table, &off, m_funcDesc_table)) { found_symbol = true; break; } symbol_table = symbol_table->m_next; } if (!found_symbol) return false; ElfStringTable* string_table = get_string_table(string_table_index); /// <-- bad string_table_index if symbol_table->lookup returned bad "true" if (string_table == NULL) { m_status = NullDecoder::file_invalid; /// <-- all future calls to ElfFile::decode will return false return false; } if (offset) *offset = off; return string_table->string_at(pos_in_string_table, buf, buflen); }