From 9bae83f89fa644d1572d2ce7dfd67170bf6ce3c2 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 21 Aug 2012 08:32:01 +0000 Subject: [PATCH] * addr2line.c (fill_lines): need check and cast of the file size of target binary because there are some platforms which off_t > size_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ addr2line.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06a6eb892f..34f19a1095 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Aug 21 17:29:56 2012 NAKAMURA Usaku + + * addr2line.c (fill_lines): need check and cast of the file size of + target binary because there are some platforms which off_t > size_t. + Tue Aug 21 17:07:58 2012 URABE Shyouhei * .travis.yml (compiler): [experimental] clang support. diff --git a/addr2line.c b/addr2line.c index 2b0bb90616..b8d103eb7b 100644 --- a/addr2line.c +++ b/addr2line.c @@ -1,6 +1,6 @@ /********************************************************************** - addr2line.h - + addr2line.c - $Author$ @@ -458,9 +458,14 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink, fprintf(stderr, "lseek: %s\n", strerror(e)); return; } + if (filesize > SIZE_MAX) { + close(fd); + fprintf(stderr, "Too large file %s\n", binary_filename); + return; + } lseek(fd, 0, SEEK_SET); /* async-signal unsafe */ - file = (char *)mmap(NULL, filesize, PROT_READ, MAP_SHARED, fd, 0); + file = (char *)mmap(NULL, (size_t)filesize, PROT_READ, MAP_SHARED, fd, 0); if (file == MAP_FAILED) { int e = errno; close(fd); @@ -470,7 +475,7 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink, current_line->fd = fd; current_line->mapped = file; - current_line->mapped_size = filesize; + current_line->mapped_size = (size_t)filesize; for (i = 0; i < num_traces; i++) { const char *path;