The code relied on the assumption that the program headers will fit within FILEBUF_SIZE bytes from beginning of file. This is usually true in practice, but is not guaranteed, and as a result Graphene could read outside of the allocated buffer.
Instead, we perform two reads: first for the ELF header, then for the program headers.
Description of the changes
The code relied on the assumption that the program headers will fit within FILEBUF_SIZE bytes from beginning of file. This is usually true in practice, but is not guaranteed, and as a result Graphene could read outside of the allocated buffer.
Instead, we perform two reads: first for the ELF header, then for the program headers.
How to test this PR?
Existing tests should be enough.
This change is