diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
deleted file mode 100644
index 44f2fb5e5e8cecd26818e7c9aa1f052fb33f6a61..0000000000000000000000000000000000000000
--- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,71 +0,0 @@
-**Description:**
-
-**Issue number:**
-
-**Test & Result:**
-
-**CodeCheck:**
-
-
- 类型 | 自检项 | 自检结果 |
-
-
- 多线程相关 | 在类的成员变量中定义了vector/map/list等容器类型,且在多个成员函数中有操作时,需要加锁保护 | 自检结果: |
-
-
- 定义全局变量,在多个函数中都有操作时,需要加锁保护 | 自检结果: |
-
-
- 内存相关 | 调用外部接口时,确认是否对返回值做了判断,尤其外部接口返回了nullptr的情况,避免进程崩溃 | 自检结果: |
-
-
- 调用安全函数时,如memcpy_s等,是否检查其返回值 | 自检结果: |
-
-
- 检查函数中是否涉及了内存或资源申请(如文件句柄),注意每个异常退出流程,是否都已经将资源释放(推荐使用RAII) | 自检结果: |
-
-
-
- 隐式内存分配场景:realpath、ReadParcelable序列化、cJSON相关函数时等,需主动释放或使用智能指针 | 自检结果: |
-
-
- 校验外部输入 | 使用nlohmann:json解析外部输入时,需判断参数类型是否符合预期 | 自检结果: |
-
-
- 所有外部输入均不可信,需判断外部输入是否直接作为内存分配的大小,数组下标、循环条件、SQL查询等 | 自检结果: |
-
-
- 外部输入的路径不可信,需使用realpath做标准化处理,并判断路径的合法性 | 自检结果: |
-
-
- 外部输入包括对外提供的接口,IPC的proxy/stub接口,序列化/反序列化接口等 | 自检结果: |
-
-
-
- 数学运算 | 代码中是否混合了加减乘除等运算,需检查是否可能导致整数溢出或符号翻转 | 自检结果: |
-
-
- 需检查代码是否有高精度数字转换为低精度的操作,如果必须,建议使用C++安全类型转换接口 | 自检结果: |
-
-
-
- 秘钥相关 | 如变量临时保存了口令、秘钥等,需要在使用完成后及时清空(内存memset掉) | 自检结果: |
-
-
- 权限相关 | 作为系统服务对外提供了接口,是否做了权限保护和校验(如需要),只允许申请了权限的应用访问 | 自检结果: |
-
-
- 内核对外提供了设备节点,是否做了权限保护,只允许特定的系统服务访问 | 自检结果: |
-
-
-
- 内核操作 | 是否有mmap操作,并使用remap_pfn_range进行地址映射时,校验起始地址是否是用户态输入且没有做合法性校验 | 自检结果: |
-
-
- 是否有copy_from_user,并对外部输入的数据做了长度校验,以防止缓冲区溢出 | 自检结果: |
-
-
- 是否有使用copy_to_user,并在返回到用户态时,对数据做了完整初始化,或使用memset情况后再赋值 | 自检结果: |
-
-
-
\ No newline at end of file
diff --git a/interfaces/kits/js/src/mod_fs/properties/listfile.cpp b/interfaces/kits/js/src/mod_fs/properties/listfile.cpp
index 7772979959f91cdd3f21702a5df9ccbe1b1da98a..80862785360bf46a696e139e753c0f220a7773b2 100755
--- a/interfaces/kits/js/src/mod_fs/properties/listfile.cpp
+++ b/interfaces/kits/js/src/mod_fs/properties/listfile.cpp
@@ -326,13 +326,67 @@ napi_value ListFile::Sync(napi_env env, napi_callback_info info)
NError(EINVAL).ThrowErr(env);
return nullptr;
}
- auto [succPath, path, unused] = NVal(env, funcArg[NARG_POS::FIRST]).ToUTF8StringPath();
- if (!succPath) {
- HILOGE("Invalid path");
+ // get path type:arraybuffer || string
+ napi_valuetype valueType;
+ napi_status status = napi_typeof(env, funcArg[NARG_POS::FIRST], &valueType);
+ if (status != napi_ok) {
NError(EINVAL).ThrowErr(env);
return nullptr;
}
- if (!GetOptionArg(env, funcArg, g_optionArgs, string(path.get()))) {
+ std::string pathStr;
+ if(valueType==napi_string){//string
+ auto [succPath, path, unused] = NVal(env, funcArg[NARG_POS::FIRST]).ToUTF8StringPath();
+ if (!succPath) {
+ HILOGE("Invalid path");
+ NError(EINVAL).ThrowErr(env);
+ return nullptr;
+ }
+ pathStr = std::string(path.get());
+ } else if(valueType==napi_object){//arraybuffer
+ bool isArrayBuffer=false;
+ status = napi_is_arraybuffer(env, funcArg[NARG_POS::FIRST], &isArrayBuffer);
+ if (status != napi_ok) {
+ NError(EINVAL).ThrowErr(env);
+ return nullptr;
+ }
+ if(!IsArrayBuffer) {
+ HILOGE("Type of path unmathched:expect string|arraybuffer|uri");
+ NError(EINVAL).ThrowErr(env);
+ return nullptr;
+ }
+ size_t arrayBufferLength;
+ void* arrayBufferData;
+ //get [arraybuffer pointer] and its [length] to transfer to string
+ status = napi_get_arraybuffer_info(env, funcArg[NARG_POS::FIRST], &arrayBufferData, &arrayBufferLength);
+ if (status != napi_ok) {
+ NError(EINVAL).ThrowErr(env);
+ return nullptr;
+ }
+ //create reference to assert arraybuffer alive while being used
+
+ napi_ref arrayBufferRef;
+ status = napi_create_reference(env, funcArg[NARG_POS::FIRST], 1, &arrayBufferRef);
+ if (status != napi_ok) {
+ NError(EINVAL).ThrowErr(env);
+ return nullptr;
+ }
+ //get path
+ pathStr = std::string(static_cast