From 658d6240ff2c2774d66ade591ddae59648eb5a73 Mon Sep 17 00:00:00 2001 From: zhou_xq Date: Fri, 23 May 2025 13:38:05 +0800 Subject: [PATCH] Fix the issue where the realpath function cannot read the sandbox path Signed-off-by: zhou_xq --- interfaces/innerkits/unwinder/src/elf/elf_factory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp index cbe670628..f6c217295 100644 --- a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp +++ b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp @@ -205,12 +205,12 @@ std::shared_ptr CompressHapElfFactory::Create() DFXLOGE("current hap map item or prev map item , maybe pc is wrong?"); return nullptr; } - std::string realPath = filePath_; - if (!RealPath(filePath_, realPath) || !EndsWith(realPath, ".hap") || !StartsWith(realPath, "/proc")) { - DFXLOGE("Illegal file path, please check file: %{public}s", realPath.c_str()); + // Do not use the realpath function, as it will fail when filePath_ is a sandbox path. + if (!StartsWith(filePath_, "/proc") || !EndsWith(filePath_, ".hap")) { + DFXLOGD("Illegal file path, please check file: %{public}s", filePath_.c_str()); return nullptr; } - int fd = OHOS_TEMP_FAILURE_RETRY(open(realPath.c_str(), O_RDONLY)); + int fd = OHOS_TEMP_FAILURE_RETRY(open(filePath_.c_str(), O_RDONLY)); if (fd < 0) { DFXLOGE("Failed to open hap file, errno(%{public}d)", errno); return nullptr; -- Gitee