summaryrefslogtreecommitdiff
path: root/Libraries/LibELF/ELFImage.h
diff options
context:
space:
mode:
authorAndrew Kaster <andrewdkaster@gmail.com>2020-01-10 18:25:12 -0700
committerAndreas Kling <awesomekling@gmail.com>2020-01-13 13:03:30 +0100
commit046d6a6bbb667b7c978b63ddf4315b04794939f9 (patch)
tree4971f5fad71e6bec8c40522cc70c28b29820ee79 /Libraries/LibELF/ELFImage.h
parentfe0eb04a229bcc76679a7e61e6007803a338e311 (diff)
downloadserenity-046d6a6bbb667b7c978b63ddf4315b04794939f9.zip
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
Diffstat (limited to 'Libraries/LibELF/ELFImage.h')
-rw-r--r--Libraries/LibELF/ELFImage.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibELF/ELFImage.h b/Libraries/LibELF/ELFImage.h
index d4529d79ba..c03b8f9991 100644
--- a/Libraries/LibELF/ELFImage.h
+++ b/Libraries/LibELF/ELFImage.h
@@ -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;