mirror of
https://github.com/QuasarApp/ELFIO.git
synced 2025-05-10 10:09:33 +00:00
Don't access a note entry in case namesz is less than 1
This commit is contained in:
parent
a935b5472e
commit
453929342f
25
.vscode/launch.json
vendored
25
.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "g++ build and debug active file",
|
"name": "Run ELFIO Tests",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/ELFIOTest/ELFIOTest",
|
"program": "${workspaceFolder}/ELFIOTest/ELFIOTest",
|
||||||
@ -22,7 +22,28 @@
|
|||||||
"ignoreFailures": true
|
"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"
|
"miDebuggerPath": "/usr/bin/gdb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
18
.vscode/tasks.json
vendored
18
.vscode/tasks.json
vendored
@ -2,7 +2,7 @@
|
|||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "g++ build",
|
"label": "ELFIO Test build",
|
||||||
"command": "make",
|
"command": "make",
|
||||||
"args": [
|
"args": [
|
||||||
"INCLUDES=-I..",
|
"INCLUDES=-I..",
|
||||||
@ -15,6 +15,22 @@
|
|||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"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"
|
"version": "2.0.0"
|
||||||
|
@ -74,9 +74,10 @@ class note_section_accessor_template
|
|||||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
type = convertor( *(const Elf_Word*)( pData + 2*align ) );
|
type = convertor( *(const Elf_Word*)( pData + 2*align ) );
|
||||||
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
|
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];
|
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 ) {
|
namesz + descSize > max_name_size ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user