diff options
author | Roland McGrath <roland@redhat.com> | 2008-08-26 07:20:29 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2008-08-26 07:20:29 +0000 |
commit | 122f388b300a489b54829d80f5e5fffb3f743ab7 (patch) | |
tree | e07f0734362c179a27ee7c6906b1148ebf6e6b86 /libdwfl/dwfl_module_getdwarf.c | |
parent | 513ebdc3212d923e5513dbc1fc222eaae808ecae (diff) | |
download | android_external_elfutils-122f388b300a489b54829d80f5e5fffb3f743ab7.tar.gz android_external_elfutils-122f388b300a489b54829d80f5e5fffb3f743ab7.tar.bz2 android_external_elfutils-122f388b300a489b54829d80f5e5fffb3f743ab7.zip |
propagate from branch 'com.redhat.elfutils.pmachata.threads' (head 6db56f08d1ba946c22c9bcfaec0ddeb6532e1dcc)
to branch 'com.redhat.elfutils.roland.pending' (head d0bf16e5588ef191b1541ac0d07d841c1cf52fc9)
Diffstat (limited to 'libdwfl/dwfl_module_getdwarf.c')
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index f5ee314b..652383be 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -72,13 +72,20 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file) file->elf = elf_begin (file->fd, ELF_C_READ_MMAP_PRIVATE, NULL); } + if (unlikely (elf_kind (file->elf) != ELF_K_ELF)) + { + close (file->fd); + file->fd = -1; + return DWFL_E_BADELF; + } + GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (file->elf, &ehdr_mem); if (ehdr == NULL) { elf_error: close (file->fd); file->fd = -1; - return DWFL_E_LIBELF; + return DWFL_E (LIBELF, elf_errno ()); } /* The addresses in an ET_EXEC file are absolute. The lowest p_vaddr of |