libelf: Always set ELF maxsize when reading an ELF file for sanity checks.
authorMark Wielaard <mjw@redhat.com>
Wed, 26 Oct 2016 11:08:52 +0000 (13:08 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 10 Nov 2016 11:11:00 +0000 (12:11 +0100)
commit191000fdedba3fafe4d5b8cddad3f3318b49c3fb
treea5d69e218f1a4f183ac2e88299412b90c09d3c6c
parentee38b26dc14f52eb8596e638776319ebc4213d36
libelf: Always set ELF maxsize when reading an ELF file for sanity checks.

There are various sanity checks that depend on knowing the file size
of the underlying ELF file which we only used when mmapping the ELF file.
Although we probably won't crash if we use pread to try to read from
the file, we still might return completely bogus data structures. This
could cause us to malloc insane amounts of memory.

Always try to get the maxsize when unknown in elf_begin.c (read_file).

https://bugzilla.redhat.com/show_bug.cgi?id=1388057

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/elf_begin.c