mirror of
https://github.com/serge1/ELFIO.git
synced 2024-12-27 12:17:28 +00:00
Make sure that dynamic section entry size is larger than ElfXX_Dyn structure
This commit is contained in:
parent
cf954a8d42
commit
ee891ca7c9
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -102,7 +102,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/tests/elfio_fuzzer",
|
"program": "${workspaceFolder}/tests/elfio_fuzzer",
|
||||||
"args": [
|
"args": [
|
||||||
"crash-98819328ee414bbba1ee50073d66c0727d60a7af"
|
"oom-9025696a52c7f5cb94d482225a6b3727e9691f5b"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}/tests",
|
"cwd": "${workspaceFolder}/tests",
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,17 @@ template <class S> class dynamic_section_accessor_template
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
Elf_Xword get_entries_num() const
|
Elf_Xword get_entries_num() const
|
||||||
{
|
{
|
||||||
|
size_t needed_entry_size = -1;
|
||||||
|
if ( elf_file.get_class() == ELFCLASS32 ) {
|
||||||
|
needed_entry_size = sizeof( Elf32_Dyn );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
needed_entry_size = sizeof( Elf64_Dyn );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ( 0 == entries_num ) &&
|
if ( ( 0 == entries_num ) &&
|
||||||
( 0 != dynamic_section->get_entry_size() ) ) {
|
( 0 != dynamic_section->get_entry_size() &&
|
||||||
|
dynamic_section->get_entry_size() >= needed_entry_size ) ) {
|
||||||
entries_num =
|
entries_num =
|
||||||
dynamic_section->get_size() / dynamic_section->get_entry_size();
|
dynamic_section->get_size() / dynamic_section->get_entry_size();
|
||||||
Elf_Xword i;
|
Elf_Xword i;
|
||||||
@ -134,7 +143,8 @@ template <class S> class dynamic_section_accessor_template
|
|||||||
// Check unusual case when dynamic section has no data
|
// Check unusual case when dynamic section has no data
|
||||||
if ( dynamic_section->get_data() == nullptr ||
|
if ( dynamic_section->get_data() == nullptr ||
|
||||||
( index + 1 ) * dynamic_section->get_entry_size() >
|
( index + 1 ) * dynamic_section->get_entry_size() >
|
||||||
dynamic_section->get_size() ) {
|
dynamic_section->get_size() ||
|
||||||
|
dynamic_section->get_entry_size() < sizeof( T ) ) {
|
||||||
tag = DT_NULL;
|
tag = DT_NULL;
|
||||||
value = 0;
|
value = 0;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user