1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 03:53:43 +01:00

Improve ELF valid_object() helper

Ensures the ELF header version is valid.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
This commit is contained in:
Zachary T Welch 2010-11-29 20:10:07 -08:00 committed by Arun Sharma
parent af88cab09f
commit 5007f8c794

View file

@ -32,11 +32,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
HIDDEN int
elf_w (valid_object) (struct elf_image *ei)
{
if (ei->size <= EI_CLASS)
if (ei->size <= EI_VERSION)
return 0;
return (memcmp (ei->image, ELFMAG, SELFMAG) == 0
&& ((uint8_t *) ei->image)[EI_CLASS] == ELF_CLASS);
&& ((uint8_t *) ei->image)[EI_CLASS] == ELF_CLASS
&& ((uint8_t *) ei->image)[EI_VERSION] != EV_NONE
&& ((uint8_t *) ei->image)[EI_VERSION] <= EV_CURRENT);
}