Do not index past the end of the chain table

This commit is contained in:
Semi Malinen 2014-10-30 14:29:33 +02:00
parent b830e5e452
commit 695a05dc5d

View File

@ -88,13 +88,15 @@ class symbol_section_accessor
if ( 0 != get_hash_table_index() ) {
Elf_Word nbucket = *(Elf_Word*)hash_section->get_data();
Elf_Word nchain = *(Elf_Word*)( hash_section->get_data() +
sizeof( Elf_Word ) );
Elf_Word val = elf_hash( (const unsigned char*)name.c_str() );
Elf_Word y = *(Elf_Word*)( hash_section->get_data() +
( 2 + val % nbucket ) * sizeof( Elf_Word ) );
std::string str;
get_symbol( y, str, value, size, bind, type, section_index, other );
while ( str != name && STN_UNDEF != y ) {
while ( str != name && STN_UNDEF != y && y < nchain ) {
y = *(Elf_Word*)( hash_section->get_data() +
( 2 + nbucket + y ) * sizeof( Elf_Word ) );
get_symbol( y, str, value, size, bind, type, section_index, other );