summaryrefslogtreecommitdiff
path: root/addr2line.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 17:21:12 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 17:21:12 +0000
commit585afbbc6a833e91cd2e51b8faeece2248c0cc16 (patch)
treea47c36c7d471a24152764e8df451ce482fbabc31 /addr2line.c
parent4da6fa28f884329e04b3916565b6ba674705345a (diff)
* vm_dump.c (rb_vm_bugreport): revert r38533.
* addr2line.c (fill_lines): add ELF sanity check. [Bug #7597] [ruby-dev:46786] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'addr2line.c')
-rw-r--r--addr2line.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/addr2line.c b/addr2line.c
index e102abba4f..04a48e751d 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -493,6 +493,16 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
return;
}
+ ehdr = (ElfW(Ehdr) *)file;
+ if (memcmp(ehdr->e_ident, "\177ELF", 4) != 0) {
+ /*
+ * Huh? Maybe filename was overridden by setproctitle() and
+ * it match non-elf file.
+ */
+ close(fd);
+ return;
+ }
+
current_line->fd = fd;
current_line->mapped = file;
current_line->mapped_size = (size_t)filesize;
@@ -506,7 +516,6 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
}
}
- ehdr = (ElfW(Ehdr) *)file;
shdr = (ElfW(Shdr) *)(file + ehdr->e_shoff);
shstr_shdr = shdr + ehdr->e_shstrndx;