mirror of
https://github.com/serge1/ELFIO.git
synced 2025-03-20 04:21:25 +00:00
Prevent a crash when working with MN10300 ELF file
This commit is contained in:
parent
2ed975be62
commit
5ec1fc8949
@ -686,11 +686,12 @@ class dump
|
|||||||
void* desc;
|
void* desc;
|
||||||
Elf_Word descsz;
|
Elf_Word descsz;
|
||||||
|
|
||||||
notes.get_note( j, type, name, desc, descsz );
|
if ( notes.get_note(j, type, name, desc, descsz) ) {
|
||||||
// 'name' usually contains \0 at the end. Try to fix it
|
// 'name' usually contains \0 at the end. Try to fix it
|
||||||
name = name.c_str();
|
name = name.c_str();
|
||||||
note( out, j, type, name );
|
note( out, j, type, name );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,13 @@ class note_section_accessor
|
|||||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
type = convertor( *(Elf_Word*)( pData + 2*sizeof( Elf_Word ) ) );
|
type = convertor( *(Elf_Word*)( pData + 2*sizeof( Elf_Word ) ) );
|
||||||
Elf_Word namesz = convertor( *(Elf_Word*)( pData ) );
|
Elf_Word namesz = convertor( *(Elf_Word*)( pData ) );
|
||||||
name.assign( pData + 3*sizeof( Elf_Word ), namesz );
|
|
||||||
descSize = convertor( *(Elf_Word*)( pData + sizeof( namesz ) ) );
|
descSize = convertor( *(Elf_Word*)( pData + sizeof( namesz ) ) );
|
||||||
|
Elf_Word max_name_size = note_section->get_size() - note_start_positions[index];
|
||||||
|
if ( namesz > max_name_size ||
|
||||||
|
namesz + descSize > max_name_size ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
name.assign( pData + 3 * sizeof( Elf_Word ), namesz );
|
||||||
if ( 0 == descSize ) {
|
if ( 0 == descSize ) {
|
||||||
desc = 0;
|
desc = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user