summaryrefslogtreecommitdiff
path: root/src/elfxx.h
diff options
context:
space:
mode:
authorArun Sharma <asharma@fb.com>2011-01-23 17:55:55 -0800
committerArun Sharma <asharma@fb.com>2011-01-23 17:55:55 -0800
commita83e96cc1cc48c6c229d9462ab13ef6479a84143 (patch)
tree97f5d1e92ae9d99cc30e742d60b21e3486bb5042 /src/elfxx.h
parent5007f8c7942fb50b9263f3d151e4a11530021e90 (diff)
downloadlibunwind-a83e96cc1cc48c6c229d9462ab13ef6479a84143.tar.gz
Some entries in /proc/<pid>/maps are not ELF files, so add check
in elf_map_image() to ensure mapped files have a valid ELF header. Signed-off-by: Zachary T Welch <zwelch@codesourcery.com> Signed-off-by: Arun Sharma <asharma@fb.com>
Diffstat (limited to 'src/elfxx.h')
-rw-r--r--src/elfxx.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/elfxx.h b/src/elfxx.h
index 7742806b..e316970b 100644
--- a/src/elfxx.h
+++ b/src/elfxx.h
@@ -43,6 +43,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# define elf_w(x) _Uelf64_##x
#endif
+extern int elf_w (valid_object) (struct elf_image *ei);
+extern int elf_w (get_proc_name) (unw_addr_space_t as,
+ pid_t pid, unw_word_t ip,
+ char *buf, size_t len,
+ unw_word_t *offp);
+
static inline int
elf_map_image (struct elf_image *ei, const char *path)
{
@@ -65,11 +71,11 @@ elf_map_image (struct elf_image *ei, const char *path)
if (ei->image == MAP_FAILED)
return -1;
+ if (!elf_w (valid_object) (ei))
+ {
+ munmap(ei->image, ei->size);
+ return -1;
+ }
+
return 0;
}
-
-extern int elf_w (valid_object) (struct elf_image *ei);
-extern int elf_w (get_proc_name) (unw_addr_space_t as,
- pid_t pid, unw_word_t ip,
- char *buf, size_t len,
- unw_word_t *offp);