Ensures the ELF header version is valid.
Signed-off-by: Zachary T Welch <[email protected]>
diff --git a/src/elfxx.c b/src/elfxx.c
index 06cc9bb..7ed44ba 100644
--- a/src/elfxx.c
+++ b/src/elfxx.c
@@ -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);
}
--
1.7.2.2
_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel