Skip to content
Snippets Groups Projects
Commit 45392934 authored by Serge Lamikhov-Center's avatar Serge Lamikhov-Center
Browse files

Don't access a note entry in case namesz is less than 1

parent a935b547
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"name": "Run ELFIO Tests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/ELFIOTest/ELFIOTest",
......@@ -22,7 +22,28 @@
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build",
"preLaunchTask": "ELFIO Test build",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "Run ELF Dump",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/examples/elfdump/elfdump",
"args": ["test"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "ELF Dump Build",
"miDebuggerPath": "/usr/bin/gdb"
}
]
......
......@@ -2,7 +2,7 @@
"tasks": [
{
"type": "shell",
"label": "g++ build",
"label": "ELFIO Test build",
"command": "make",
"args": [
"INCLUDES=-I..",
......@@ -15,6 +15,22 @@
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "ELF Dump Build",
"command": "make",
"args": [
"INCLUDES=-I..",
"CXXFLAGS='-g -O0'"
],
"options": {
"cwd": "${workspaceRoot}",
},
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
......
......@@ -74,9 +74,10 @@ class note_section_accessor_template
const endianess_convertor& convertor = elf_file.get_convertor();
type = convertor( *(const Elf_Word*)( pData + 2*align ) );
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
Elf_Xword max_name_size = note_section->get_size() - note_start_positions[index];
if ( namesz > max_name_size ||
if ( namesz < 1 ||
namesz > max_name_size ||
namesz + descSize > max_name_size ) {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment