From ba75dfa95f6d1871bd8999843009fdd0222efa09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Wed, 9 May 2018 12:41:01 +0200 Subject: [PATCH] Fix eh_elf path error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function `readlink` does not null-terminate its stringsā€¦ --- stack_walker/stack_walker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stack_walker/stack_walker.cpp b/stack_walker/stack_walker.cpp index 9bf96aa..0d8f3ef 100644 --- a/stack_walker/stack_walker.cpp +++ b/stack_walker/stack_walker.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -44,10 +45,12 @@ std::string readlink_rec(const char* path) { strcpy(buf[1], path); do { - int rc = readlink(buf[parity], buf[1-parity], 1024); + ssize_t rc = readlink(buf[parity], buf[1-parity], 1024); parity = 1 - parity; if(rc < 0) break; + else + buf[parity][rc] = '\0'; } while(true); return std::string(buf[1 - parity]);