summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-07-14 17:53:45 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-07-14 17:54:48 +0900
commitdb1c30b37fb0a837724cf5813e8684edc2639222 (patch)
treeab03e19de1f4f82a9b8c0b61c54e73e74a4b3f82
parent47e571c9510a6d6e3f7d98a8a8800f391694bd19 (diff)
addr2line.c (main_exe_path): avoid SEGV when /proc is not available
readlink would return -1 if /proc is not mounted. Coverity Scan found this issue.
-rw-r--r--addr2line.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/addr2line.c b/addr2line.c
index 1871a52157..45cae6a132 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -2050,6 +2050,7 @@ main_exe_path(void)
{
# define PROC_SELF_EXE "/proc/self/exe"
ssize_t len = readlink(PROC_SELF_EXE, binary_filename, PATH_MAX);
+ if (len < 0) return 0;
binary_filename[len] = 0;
return len;
}