diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 43e199e200..8024e66535 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10529,6 +10529,9 @@ bool AbilityManagerService::ParseJsonFromBoot(nlohmann::json jsonObj, const std: } } } + if (!jsonObj.contains("exposed_white_list")) { + return false; + } nlohmann::json exportWhiteJsonList = jsonObj["exposed_white_list"]; for (const auto& it : exportWhiteJsonList) { if (it.is_string()) { diff --git a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp index b89cfe266b..02f889cae8 100644 --- a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp +++ b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp @@ -262,10 +262,16 @@ bool DeepLinkReserveConfig::ReadFileInfoJson(const std::string &filePath, nlohma return false; } + char path[PATH_MAX] = {0}; + if (realpath(filePath.c_str(), path) == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "realpath error, errno is %{public}d.", errno); + return false; + } + std::fstream in; char errBuf[256]; errBuf[0] = '\0'; - in.open(filePath, std::ios_base::in); + in.open(path, std::ios_base::in); if (!in.is_open()) { strerror_r(errno, errBuf, sizeof(errBuf)); TAG_LOGE(AAFwkTag::ABILITYMGR, "the file cannot be open due to %{public}s", errBuf); diff --git a/services/abilitymgr/src/rdb/parser_util.cpp b/services/abilitymgr/src/rdb/parser_util.cpp index 4738451f73..d90d514662 100644 --- a/services/abilitymgr/src/rdb/parser_util.cpp +++ b/services/abilitymgr/src/rdb/parser_util.cpp @@ -156,7 +156,13 @@ bool ParserUtil::ReadFileIntoJson(const std::string &filePath, nlohmann::json &j return false; } - std::ifstream fin(filePath); + char path[PATH_MAX] = {0}; + if (realpath(filePath.c_str(), path) == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "realpath error, errno is %{public}d.", errno); + return false; + } + + std::ifstream fin(path); if (!fin.is_open()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "File path exception."); return false;