mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-14 03:41:22 +00:00
Data size boundary check for dynamic section reader
Permit section data allocation for size equal to 0
This commit is contained in:
parent
cde39c9d45
commit
79ecb3fabc
@ -126,7 +126,8 @@ class dynamic_section_accessor
|
||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||
|
||||
// Check unusual case when dynamic section has no data
|
||||
if( dynamic_section->get_data() == 0 ) {
|
||||
if( dynamic_section->get_data() == 0 ||
|
||||
( index + 1 ) * dynamic_section->get_entry_size() > dynamic_section->get_size() ) {
|
||||
tag = DT_NULL;
|
||||
value = 0;
|
||||
return;
|
||||
|
@ -211,12 +211,13 @@ class section_impl : public section
|
||||
stream.read( reinterpret_cast<char*>( &header ), sizeof( header ) );
|
||||
|
||||
Elf_Xword size = get_size();
|
||||
if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() &&
|
||||
0 != size ) {
|
||||
if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() ) {
|
||||
data = new char[size];
|
||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||
stream.read( data, size );
|
||||
data_size = size;
|
||||
if ( 0 != size ) {
|
||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||
stream.read( data, size );
|
||||
data_size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user