diff --git a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp index a39784e9ccecc7ef94bd657ebc39be5bb019f39f..5328e89a9fbdf31e4d73bfcbaf017b24afb41165 100644 --- a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp +++ b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp @@ -203,11 +203,12 @@ std::shared_ptr CompressHapElfFactory::Create() DFXLOGE("current hap map item or prev map item , maybe pc is wrong?"); return nullptr; } - if (!StartsWith(filePath_, "/proc") || !EndsWith(filePath_, ".hap")) { - DFXLOGD("Illegal file path, please check file: %{public}s", filePath_.c_str()); + std::string realPath = filePath_; + if (!RealPath(filePath_, realPath) || !StartsWith(realPath, "/proc") || !EndsWith(realPath, ".hap")) { + DFXLOGD("Illegal file path, please check file: %{public}s", realPath.c_str()); return nullptr; } - int fd = OHOS_TEMP_FAILURE_RETRY(open(filePath_.c_str(), O_RDONLY)); + int fd = OHOS_TEMP_FAILURE_RETRY(open(realPath.c_str(), O_RDONLY)); if (fd < 0) { DFXLOGE("Failed to open hap file, errno(%{public}d)", errno); return nullptr;