mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
LibELF: Add methods to validate the ELF and program headers
These will make sure there's no funny business or funny offsets in the main ELF header or each Program Header. More can still be done (like validating section headers), but this is a good start
This commit is contained in:
parent
fe0eb04a22
commit
046d6a6bbb
3 changed files with 181 additions and 5 deletions
|
@ -14,7 +14,7 @@ public:
|
|||
bool is_valid() const { return m_valid; }
|
||||
bool parse();
|
||||
|
||||
bool is_within_image(const void* address, size_t size)
|
||||
bool is_within_image(const void* address, size_t size) const
|
||||
{
|
||||
if (address < m_buffer)
|
||||
return false;
|
||||
|
@ -174,6 +174,9 @@ public:
|
|||
|
||||
VirtualAddress entry() const { return VirtualAddress(header().e_entry); }
|
||||
|
||||
static bool validate_elf_header(const Elf32_Ehdr& elf_header, size_t file_size);
|
||||
static bool validate_program_headers(const Elf32_Ehdr& elf_header, size_t file_size, u8* buffer, size_t buffer_size, String& interpreter_path);
|
||||
|
||||
private:
|
||||
bool parse_header();
|
||||
const char* raw_data(unsigned offset) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue