aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-25 16:14:15 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-25 16:14:15 +0000
commitc5be8dfe7c14b4ec16960f065fc54d4ba0305b18 (patch)
tree22c7f18113052c5af71277d17e578b685afb5da6
parent9c7892202fa03078d7dbce48143c8b758fa13f2b (diff)
parent8d7c0f4f09f6560aae308ede8e75018bd8299942 (diff)
downloadbionic-c5be8dfe7c14b4ec16960f065fc54d4ba0305b18.tar.gz
Merge "linker: use realpath instead of readlink when getting the symlink path" into main
-rw-r--r--linker/linker_main.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 77769f553..f966e04db 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -29,6 +29,7 @@
#include "linker_main.h"
#include <link.h>
+#include <stdlib.h>
#include <sys/auxv.h>
#include "linker.h"
@@ -222,9 +223,9 @@ static ExecutableInfo get_executable_info(const char* arg_path) {
// Path might be a symlink
char sym_path[PATH_MAX];
- ssize_t sym_path_len = readlink(exe_path, sym_path, sizeof(sym_path));
- if (sym_path_len > 0 && sym_path_len < static_cast<ssize_t>(sizeof(sym_path))) {
- result.path = std::string(sym_path, sym_path_len);
+ auto ret = realpath(exe_path, sym_path);
+ if (ret != nullptr) {
+ result.path = std::string(sym_path, strlen(sym_path));
} else {
result.path = std::string(exe_path, strlen(exe_path));
}