From a0891ba8c474648a7b707767695f4bdb1e514254 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 29 Apr 2024 14:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=97=E9=99=90worker=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=98=AF=20'abcs/'=20=E5=BC=80=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sodanotgreen --- frameworks/native/runtime/js_worker.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frameworks/native/runtime/js_worker.cpp b/frameworks/native/runtime/js_worker.cpp index 658447e90a..ce98b6aa30 100644 --- a/frameworks/native/runtime/js_worker.cpp +++ b/frameworks/native/runtime/js_worker.cpp @@ -54,6 +54,7 @@ constexpr int32_t API8 = 8; constexpr int32_t API12 = 12; const std::string BUNDLE_NAME_FLAG = "@bundle:"; const std::string CACHE_DIRECTORY = "el2"; +const std::string RESTRICTED_PREFIX_PATH = "abcs/"; const int PATH_THREE = 3; #ifdef APP_USE_ARM constexpr char ARK_DEBUGGER_LIB_PATH[] = "/system/lib/platformsdk/libark_debugger.z.so"; @@ -246,6 +247,10 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf } filePath = NormalizedFileName(realPath); + // for safe reason, filePath must starts with 'abcs/' in restricted env + if (isRestricted && filePath.find(RESTRICTED_PREFIX_PATH) && workerInfo_->apiTargetVersion >= API12) { + filePath = RESTRICTED_PREFIX_PATH + filePath; + } ami = workerInfo_->codePath + filePath; TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str()); if (ami.find(CACHE_DIRECTORY) != std::string::npos) {