From d5d1f83ff497876d7a4c8f8e56338cb2734f0a6d Mon Sep 17 00:00:00 2001 From: Bobie Date: Mon, 19 Aug 2024 14:29:57 +0800 Subject: [PATCH 1/8] add template of PR Signed-off-by: Bobie --- .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 00000000..b2dcb188 --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,35 @@ +**Issue编号**: + +**描述**: + +**安全及低级编码自检:** +| 自检项 | 自检结果 | +| ------------------------------------------------------------------------------- | -------- | +| 变量使用前保证赋有效初值 | | +| 结构体预留字段也必须初始化为0,不允许出现随机值 | | +| 指针变量必须显示初始化为空 | | +| 涉及内存拷贝时合理校验目标内存大小,保证目标内存大于等于源内存 | | +| 进行字符串操作时,如字符串复制、申请字符串内存等,需要考虑字符串结束符 | | +| cJSON指针在异常分支里均需考虑内存释放(cJSON_free/cJSON_Delete),防止内存泄漏 | | +| 内存资源、文件句柄、管道资源、Socket句柄异常退出时要及时关闭 | | +| malloc申请内存后必须判断是否为空 | | +| 指针解引用或释放前判空(lamda表达式,异步任务等使用指针前需判空) | | +| 内存释放后立即置空,防止出现UAF | | +| 循环时容器的增、删、改操作,必须保证迭代器有效 | | +| 禁止将栈内存地址作为返回值或赋值给全局变量 | | +| 加法、乘法、减法操作,必须进行溢出和翻转保护,确保先校验再运算 | | +| 除法、求余操作必须进行除零保护 | | +| 循环变量用整型,禁止使用浮点型 | | +| 循环退出条件一定确保可达,防止出现死循环等问题 | | +| 不同大小结构体禁止强转 | | +| 禁止使用非安全函数,使用封装好的安全函数 | | +| 日志必须检查PassWord/位置信息/networkId/devId/uuid/udid等关键字,避免明文打印敏感信息 | | +| 对函数入参坚持先校验后使用的原则(指针判空、整型变量校验范围) | | +| 跨进程调用需注意权限校验,对外部传入的PID、tokenID进行权限校验 | | +| 共享数据均需加锁保护,并且锁配对使用 | | +| 条件变量正确加锁,消除条件变量唤醒丢失等问题 | | +| 加锁范围确保合理,避免过大或过小导致死锁问题 | | + +**TDD结果**: + +**XTS结果**: From 499355e13855f86b194ab66b53841e169c766d0c Mon Sep 17 00:00:00 2001 From: 17333770736 Date: Mon, 26 Aug 2024 17:08:17 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=95=8F=E6=84=9F=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=89=93=E5=8D=B0+=E5=8F=98=E9=87=8F=E4=B8=8A=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 17333770736 --- common/src/distributed_sched_utils.cpp | 29 ++++++++++--------- .../include/softbus_adapter/softbus_adapter.h | 1 + .../dsched_all_connect_manager.cpp | 6 ++-- .../src/softbus_adapter/softbus_adapter.cpp | 10 +++++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/common/src/distributed_sched_utils.cpp b/common/src/distributed_sched_utils.cpp index ca4e309e..14bcfe88 100644 --- a/common/src/distributed_sched_utils.cpp +++ b/common/src/distributed_sched_utils.cpp @@ -71,7 +71,7 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath) char path[PATH_MAX + 1] = { 0 }; if (inFilePath.empty() || inFilePath.length() > PATH_MAX || inFilePath.length() + 1 > MAX_CONFIG_PATH_LEN || realpath(inFilePath.c_str(), path) == nullptr) { - HILOGE("Get continue config file real path fail, inFilePath %{public}s.", inFilePath.c_str()); + HILOGE("Get continue config file real path fail, inFilePath %{public}s.", GetAnonymStr(inFilePath).c_str()); return false; } @@ -81,11 +81,11 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath) return false; } if (!std::filesystem::exists(realFilePath)) { - HILOGE("The real file path %{public}s does not exist in the file system.", realFilePath.c_str()); + HILOGE("The real file path %{public}s does not exist in the file system.", GetAnonymStr(realFilePath).c_str()); realFilePath = ""; return false; } - HILOGI("The real file path %{public}s exist in the file system.", realFilePath.c_str()); + HILOGI("The real file path %{public}s exist in the file system.", GetAnonymStr(realFilePath).c_str()); return true; } @@ -132,37 +132,38 @@ bool UpdateAllowAppList(const std::string &cfgJsonStr) int32_t LoadContinueConfig() { HILOGI("Load continue config, isMissContinueCfg %{public}d, ContinueCfgFullPath %{public}s.", - g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str()); + g_isMissContinueCfg.load(), GetAnonymStr(g_continueCfgFullPath).c_str()); std::string tempPath = g_continueCfgFullPath; if (!g_isMissContinueCfg.load() && (g_continueCfgFullPath.empty() || !IsValidPath(tempPath, g_continueCfgFullPath))) { char cfgPathBuf[MAX_CONFIG_PATH_LEN] = { 0 }; char *filePath = GetOneCfgFile(CONTINUE_CONFIG_RELATIVE_PATH.c_str(), cfgPathBuf, MAX_CONFIG_PATH_LEN); if (filePath == nullptr || filePath != cfgPathBuf) { - HILOGI("Not find continue config file, relative path %{public}s.", CONTINUE_CONFIG_RELATIVE_PATH.c_str()); + HILOGI("Not find continue config file, relative path %{public}s.", + GetAnonymStr(CONTINUE_CONFIG_RELATIVE_PATH).c_str()); g_isMissContinueCfg.store(true); g_continueCfgFullPath = ""; return ERR_OK; } g_isMissContinueCfg.store(false); g_continueCfgFullPath = std::string(filePath); - HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.", + GetAnonymStr(g_continueCfgFullPath).c_str()); } - if (g_isMissContinueCfg.load()) { HILOGI("Current device does not carry continue config file."); return ERR_OK; } - tempPath = g_continueCfgFullPath; + std::string anonymPath = GetAnonymStr(g_continueCfgFullPath); if (!IsValidPath(tempPath, g_continueCfgFullPath)) { - HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } std::ifstream in; in.open(g_continueCfgFullPath.c_str(), std::ios::binary | std::ios::in); if (!in.is_open()) { - HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } @@ -174,11 +175,11 @@ int32_t LoadContinueConfig() in.close(); if (!UpdateAllowAppList(cfgFileContent)) { - HILOGE("Update allow app list fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Update allow app list fail, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } HILOGI("Load continue config success, isMissContinueCfg %{public}d, cfgFullPath %{public}s.", - g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str()); + g_isMissContinueCfg.load(), anonymPath.c_str()); return ERR_OK; } @@ -193,12 +194,12 @@ bool CheckBundleContinueConfig(const std::string &bundleName) auto it = std::find(g_allowAppList.begin(), g_allowAppList.end(), bundleName); if (it == g_allowAppList.end()) { HILOGE("Current app is not allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.", - bundleName.c_str(), g_continueCfgFullPath.c_str()); + bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str()); return false; } HILOGI("Current app is allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.", - bundleName.c_str(), g_continueCfgFullPath.c_str()); + bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str()); return true; } diff --git a/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h b/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h index 591ded2a..6d6340c8 100644 --- a/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h +++ b/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h @@ -48,6 +48,7 @@ private: std::thread eventThread_; std::condition_variable eventCon_; std::mutex eventMutex_; + std::mutex softbusAdapterListenerMutex_; std::shared_ptr eventHandler_ = nullptr; }; } // namespace DistributedSchedule diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index a6569145..5f392ded 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -93,14 +93,16 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy() #endif char path[PATH_MAX + 1] = {0}; if (resolvedPath.length() > PATH_MAX || realpath(resolvedPath.c_str(), path) == nullptr) { - HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].", resolvedPath.c_str()); + HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].", + GetAnonymStr(resolvedPath).c_str()); return INVALID_PARAMETERS_ERR; } int32_t (*ServiceCollaborationManagerExport)(ServiceCollaborationManager_API *exportapi) = nullptr; dllHandle_ = dlopen(resolvedPath.c_str(), RTLD_LAZY); if (dllHandle_ == nullptr) { - HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", resolvedPath.c_str()); + HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", + GetAnonymStr(resolvedPath).c_str()); return NOT_FIND_SERVICE_REGISTRY; } diff --git a/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp b/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp index 4d0968ce..2c2c49f5 100644 --- a/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp @@ -173,7 +173,10 @@ int32_t SoftbusAdapter::RegisterSoftbusEventListener(const std::shared_ptr lock(softbusAdapterListenerMutex_); + softbusAdapterListener_ = listener; + } EventListener eventListener; eventListener.event = FOREGROUND_APP; eventListener.freq = EVENT_MID_FREQ; @@ -195,7 +198,10 @@ int32_t SoftbusAdapter::UnregisterSoftbusEventListener(const std::shared_ptr lock(softbusAdapterListenerMutex_); + softbusAdapterListener_ = listener; + } EventListener eventListener; eventListener.event = FOREGROUND_APP; eventListener.freq = EVENT_MID_FREQ; From fff13baa2c3f2fba9f776b5af94b5120840a9a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Sat, 24 Aug 2024 15:56:29 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../distributed_event/include/dms_sa_client.h | 3 +- .../distributed_event/src/dms_sa_client.cpp | 26 +- .../distributedWant/distributed_want_params.h | 105 ++++--- .../src/dfx/dms_continue_time_dumper.cpp | 6 +- .../distributed_want_params.cpp | 291 ++++++++++++------ .../src/distributed_sched_permission.cpp | 3 + 6 files changed, 290 insertions(+), 144 deletions(-) diff --git a/interfaces/innerkits/distributed_event/include/dms_sa_client.h b/interfaces/innerkits/distributed_event/include/dms_sa_client.h index 774235be..0aac9971 100644 --- a/interfaces/innerkits/distributed_event/include/dms_sa_client.h +++ b/interfaces/innerkits/distributed_event/include/dms_sa_client.h @@ -45,10 +45,11 @@ public: private: DmsSaClient() {}; ~DmsSaClient() {}; - bool hasSubscribeDmsSA_ = false; + std::atomic hasSubscribeDmsSA_ = false; OHOS::sptr saMgrProxy_; std::map> listeners_; std::mutex eventMutex_; + std::mutex saMgrMutex_; }; class DmsSystemAbilityStatusChange : public SystemAbilityStatusChangeStub { diff --git a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp index a4279394..5e59042d 100644 --- a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp +++ b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp @@ -47,7 +47,10 @@ bool DmsSaClient::SubscribeDmsSA() int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const sptr& listener) { HILOGI("%{public}s called, the type is %{public}d", __func__, type); - saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + { + std::lock_guard lock(saMgrMutex_); + saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + } if (saMgrProxy_ == nullptr) { HILOGE("fail to get saMgrProxy."); return AAFwk::INNER_ERR; @@ -56,11 +59,13 @@ int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const s DistributedClient distributedClient; distributedClient.RegisterDSchedEventListener(type, listener); } - std::lock_guard lock(eventMutex_); if (!hasSubscribeDmsSA_) { if (SubscribeDmsSA()) { hasSubscribeDmsSA_ = true; - listeners_[type] = listener; + { + std::lock_guard lock(eventMutex_); + listeners_[type] = listener; + } } else { return AAFwk::INNER_ERR; } @@ -71,7 +76,10 @@ int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const s int32_t DmsSaClient::DelDSchedEventListener(const DSchedEventType& type, const sptr& listener) { HILOGI("%{public}s called, the type is %{public}d", __func__, type); - saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + { + std::lock_guard lock(saMgrMutex_); + saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + } if (saMgrProxy_ == nullptr) { HILOGE("fail to get saMgrProxy."); return AAFwk::INNER_ERR; @@ -88,7 +96,10 @@ int32_t DmsSaClient::DelDSchedEventListener(const DSchedEventType& type, const s int32_t DmsSaClient::GetContinueInfo(ContinueInfo &continueInfo) { HILOGI("%{public}s called", __func__); - saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + { + std::lock_guard lock(saMgrMutex_); + saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + } if (saMgrProxy_ == nullptr) { HILOGE("fail to get saMgrProxy."); return AAFwk::INNER_ERR; @@ -103,7 +114,10 @@ int32_t DmsSaClient::GetContinueInfo(ContinueInfo &continueInfo) int32_t DmsSaClient::GetDSchedEventInfo(const DSchedEventType &type, std::vector &events) { HILOGI("%{public}s called", __func__); - saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + { + std::lock_guard lock(saMgrMutex_); + saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + } if (saMgrProxy_ == nullptr) { HILOGE("Get SA manager proxy fail."); return AAFwk::INNER_ERR; diff --git a/services/dtbschedmgr/include/distributedWant/distributed_want_params.h b/services/dtbschedmgr/include/distributedWant/distributed_want_params.h index 57eb9dfc..95565242 100644 --- a/services/dtbschedmgr/include/distributedWant/distributed_want_params.h +++ b/services/dtbschedmgr/include/distributedWant/distributed_want_params.h @@ -19,6 +19,7 @@ #include #include #include + #include "base_interfaces.h" #include "parcel.h" #include "refbase.h" @@ -57,9 +58,6 @@ public: static bool CompareInterface(const sptr iIt1, const sptr iIt2, int typeId); - static bool CompareNumberInterface(const sptr iIt1, - const sptr iIt2, int typeId); - static int GetDataType(const sptr iIt); static int GetNumberDataType(const sptr iIt); @@ -89,39 +87,29 @@ public: AAFwk::WantParams ToWantParams(); private: - enum { - VALUE_TYPE_NULL = -1, - VALUE_TYPE_BOOLEAN = 1, - VALUE_TYPE_BYTE = 2, - VALUE_TYPE_CHAR = 3, - VALUE_TYPE_SHORT = 4, - VALUE_TYPE_INT = 5, - VALUE_TYPE_LONG = 6, - VALUE_TYPE_FLOAT = 7, - VALUE_TYPE_DOUBLE = 8, - VALUE_TYPE_STRING = 9, - VALUE_TYPE_CHARSEQUENCE = 10, - VALUE_TYPE_BOOLEANARRAY = 11, - VALUE_TYPE_BYTEARRAY = 12, - VALUE_TYPE_CHARARRAY = 13, - VALUE_TYPE_SHORTARRAY = 14, - VALUE_TYPE_INTARRAY = 15, - VALUE_TYPE_LONGARRAY = 16, - VALUE_TYPE_FLOATARRAY = 17, - VALUE_TYPE_DOUBLEARRAY = 18, - VALUE_TYPE_STRINGARRAY = 19, - VALUE_TYPE_CHARSEQUENCEARRAY = 20, + static std::string BooleanQueryToStr(const sptr iIt); + static std::string ByteQueryToStr(const sptr iIt); + static std::string CharQueryToStr(const sptr iIt); + static std::string ShortQueryToStr(const sptr iIt); + static std::string IntegerQueryToStr(const sptr iIt); + static std::string LongQueryToStr(const sptr iIt); + static std::string FloatQueryToStr(const sptr iIt); + static std::string DoubleQueryToStr(const sptr iIt); + static std::string StringQueryToStr(const sptr iIt); + static std::string ArrayQueryToStr(const sptr iIt); + static std::string DistributedWantParamsQueryToStr(const sptr iIt); - VALUE_TYPE_PARCELABLE = 21, - VALUE_TYPE_PARCELABLEARRAY = 22, - VALUE_TYPE_SERIALIZABLE = 23, - VALUE_TYPE_LIST = 50, - - VALUE_TYPE_WANTPARAMS = 101, - VALUE_TYPE_ARRAY = 102, - VALUE_TYPE_FD = 103, - VALUE_TYPE_REMOTE_OBJECT = 104 - }; + static bool BooleanQueryEquals(const sptr iIt); + static bool ByteQueryEquals(const sptr iIt); + static bool CharQueryEquals(const sptr iIt); + static bool StringQueryEquals(const sptr iIt); + static bool ArrayQueryEquals(const sptr iIt); + static bool DistributedWantParamsQueryEquals(const sptr iIt); + static bool ShortQueryEquals(const sptr iIt); + static bool IntegerQueryEquals(const sptr iIt); + static bool LongQueryEquals(const sptr iIt); + static bool FloatQueryEquals(const sptr iIt); + static bool DoubleQueryEquals(const sptr iIt); bool WriteArrayToParcel(Parcel& parcel, AAFwk::IArray* ao) const; bool ReadArrayToParcel(Parcel& parcel, int type, sptr& ao); @@ -178,11 +166,52 @@ private: bool DoMarshalling(Parcel& parcel) const; bool ReadUnsupportedData(Parcel& parcel, const std::string& key, int type); - friend class DistributedWantParamWrapper; - friend class DistributedWant; - // inner use function bool NewArrayData(AAFwk::IArray* source, sptr& dest); bool NewParams(const DistributedWantParams& source, DistributedWantParams& dest); + +private: + enum { + VALUE_TYPE_NULL = -1, + VALUE_TYPE_BOOLEAN = 1, + VALUE_TYPE_BYTE = 2, + VALUE_TYPE_CHAR = 3, + VALUE_TYPE_SHORT = 4, + VALUE_TYPE_INT = 5, + VALUE_TYPE_LONG = 6, + VALUE_TYPE_FLOAT = 7, + VALUE_TYPE_DOUBLE = 8, + VALUE_TYPE_STRING = 9, + VALUE_TYPE_CHARSEQUENCE = 10, + VALUE_TYPE_BOOLEANARRAY = 11, + VALUE_TYPE_BYTEARRAY = 12, + VALUE_TYPE_CHARARRAY = 13, + VALUE_TYPE_SHORTARRAY = 14, + VALUE_TYPE_INTARRAY = 15, + VALUE_TYPE_LONGARRAY = 16, + VALUE_TYPE_FLOATARRAY = 17, + VALUE_TYPE_DOUBLEARRAY = 18, + VALUE_TYPE_STRINGARRAY = 19, + VALUE_TYPE_CHARSEQUENCEARRAY = 20, + + VALUE_TYPE_PARCELABLE = 21, + VALUE_TYPE_PARCELABLEARRAY = 22, + VALUE_TYPE_SERIALIZABLE = 23, + VALUE_TYPE_LIST = 50, + + VALUE_TYPE_WANTPARAMS = 101, + VALUE_TYPE_ARRAY = 102, + VALUE_TYPE_FD = 103, + VALUE_TYPE_REMOTE_OBJECT = 104 + }; + + friend class DistributedWantParamWrapper; + friend class DistributedWant; + using InterfaceQueryToStrFunc = std::string (*)(const sptr iIt); + using InterfaceQueryEqualsFunc = bool (*)(const sptr iIt); + static std::map interfaceQueryToStrMap; + static std::map interfaceQueryEqualsMap; + + // inner use function std::map> params_; std::map fds_; std::vector cachedUnsupportedData_; diff --git a/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp b/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp index 0caf175b..4cda4fd8 100644 --- a/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp +++ b/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp @@ -194,7 +194,7 @@ DmsDumperInfo DmsContinueTime::GetDstInfo() void DmsContinueTime::SetDurationBegin(const int32_t idx, const int64_t time) { std::lock_guard vecLock(infoMutex_); - if (durationInfo_.empty() || durationInfo_.size() <= idx) { + if (durationInfo_.empty() || durationInfo_.size() <= static_cast(idx)) { return; } durationInfo_[idx].SetBeginTime(time); @@ -203,7 +203,7 @@ void DmsContinueTime::SetDurationBegin(const int32_t idx, const int64_t time) void DmsContinueTime::SetDurationEnd(const int32_t idx, const int64_t time) { std::lock_guard vecLock(infoMutex_); - if (durationInfo_.empty() || durationInfo_.size() <= idx) { + if (durationInfo_.empty() || durationInfo_.size() <= static_cast(idx)) { return; } durationInfo_[idx].SetEndTime(time); @@ -212,7 +212,7 @@ void DmsContinueTime::SetDurationEnd(const int32_t idx, const int64_t time) void DmsContinueTime::SetDurationStrTime(const int32_t idx, const std::string info) { std::lock_guard vecLock(infoMutex_); - if (durationInfo_.empty() || durationInfo_.size() <= idx) { + if (durationInfo_.empty() || durationInfo_.size() <= static_cast(idx)) { return; } durationInfo_[idx].SetStrTime(info); diff --git a/services/dtbschedmgr/src/distributedWant/distributed_want_params.cpp b/services/dtbschedmgr/src/distributedWant/distributed_want_params.cpp index 4f6295fe..7ae1fcb3 100644 --- a/services/dtbschedmgr/src/distributedWant/distributed_want_params.cpp +++ b/services/dtbschedmgr/src/distributedWant/distributed_want_params.cpp @@ -44,6 +44,57 @@ const char* TYPE_PROPERTY = "type"; const char* VALUE_PROPERTY = "value"; const std::string TAG = "DistributedUnsupportedData"; } + +std::map DistributedWantParams::interfaceQueryToStrMap = { + std::map::value_type( + DistributedWantParams::VALUE_TYPE_BOOLEAN, &DistributedWantParams::BooleanQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_BYTE, &DistributedWantParams::ByteQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_CHAR, &DistributedWantParams::CharQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_SHORT, &DistributedWantParams::ShortQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_INT, &DistributedWantParams::IntegerQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_LONG, &DistributedWantParams::LongQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_FLOAT, &DistributedWantParams::FloatQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_DOUBLE, &DistributedWantParams::DoubleQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_STRING, &DistributedWantParams::StringQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_ARRAY, &DistributedWantParams::ArrayQueryToStr), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_WANTPARAMS, &DistributedWantParams::DistributedWantParamsQueryToStr), +}; + +std::map DistributedWantParams::interfaceQueryEqualsMap = { + std::map::value_type( + DistributedWantParams::VALUE_TYPE_BOOLEAN, &DistributedWantParams::BooleanQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_BYTE, &DistributedWantParams::ByteQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_CHAR, &DistributedWantParams::CharQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_STRING, &DistributedWantParams::StringQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_ARRAY, &DistributedWantParams::ArrayQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_WANTPARAMS, &DistributedWantParams::DistributedWantParamsQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_SHORT, &DistributedWantParams::ShortQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_INT, &DistributedWantParams::IntegerQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_LONG, &DistributedWantParams::LongQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_FLOAT, &DistributedWantParams::FloatQueryEquals), + std::map::value_type( + DistributedWantParams::VALUE_TYPE_DOUBLE, &DistributedWantParams::DoubleQueryEquals), +}; + DistributedUnsupportedData::~DistributedUnsupportedData() { if (buffer != nullptr) { @@ -114,36 +165,144 @@ DistributedUnsupportedData& DistributedUnsupportedData::operator=(DistributedUns return *this; } +std::string DistributedWantParams::BooleanQueryToStr(const sptr iIt) +{ + AAFwk::IBoolean* obj = AAFwk::IBoolean::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::ByteQueryToStr(const sptr iIt) +{ + AAFwk::IByte* obj = AAFwk::IByte::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::CharQueryToStr(const sptr iIt) +{ + AAFwk::IChar* obj = AAFwk::IChar::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::ShortQueryToStr(const sptr iIt) +{ + AAFwk::IShort* obj = AAFwk::IShort::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::IntegerQueryToStr(const sptr iIt) +{ + AAFwk::IInteger* obj = AAFwk::IInteger::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::LongQueryToStr(const sptr iIt) +{ + AAFwk::ILong* obj = AAFwk::ILong::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::FloatQueryToStr(const sptr iIt) +{ + AAFwk::IFloat* obj = AAFwk::IFloat::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::DoubleQueryToStr(const sptr iIt) +{ + AAFwk::IDouble* obj = AAFwk::IDouble::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::StringQueryToStr(const sptr iIt) +{ + AAFwk::IString* obj = AAFwk::IString::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::ArrayQueryToStr(const sptr iIt) +{ + AAFwk::IArray* obj = AAFwk::IArray::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +std::string DistributedWantParams::DistributedWantParamsQueryToStr(const sptr iIt) +{ + IDistributedWantParams* obj = IDistributedWantParams::Query(iIt); + return obj == nullptr ? "" : static_cast(obj)->ToString(); +} + +bool DistributedWantParams::BooleanQueryEquals(const sptr iIt) +{ + AAFwk::IBoolean* obj = AAFwk::IBoolean::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::ByteQueryEquals(const sptr iIt) +{ + AAFwk::IByte* obj = AAFwk::IByte::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::CharQueryEquals(const sptr iIt) +{ + AAFwk::IChar* obj = AAFwk::IChar::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::StringQueryEquals(const sptr iIt) +{ + AAFwk::IString* obj = AAFwk::IString::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::ArrayQueryEquals(const sptr iIt) +{ + AAFwk::IArray* obj = AAFwk::IArray::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::DistributedWantParamsQueryEquals(const sptr iIt) +{ + IDistributedWantParams* obj = IDistributedWantParams::Query(iIt); + return obj == nullptr ? false : static_cast(obj) + ->Equals(*static_cast(obj)); +} +bool DistributedWantParams::ShortQueryEquals(const sptr iIt) +{ + AAFwk::IShort* obj = AAFwk::IShort::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::IntegerQueryEquals(const sptr iIt) +{ + AAFwk::IInteger* obj = AAFwk::IInteger::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::LongQueryEquals(const sptr iIt) +{ + AAFwk::ILong* obj = AAFwk::ILong::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::FloatQueryEquals(const sptr iIt) +{ + AAFwk::IFloat* obj = AAFwk::IFloat::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + +bool DistributedWantParams::DoubleQueryEquals(const sptr iIt) +{ + AAFwk::IDouble* obj = AAFwk::IDouble::Query(iIt); + return obj == nullptr ? false : static_cast(obj)->Equals(*static_cast(obj)); +} + std::string DistributedWantParams::GetStringByType(const sptr iIt, int typeId) { - if (iIt == nullptr) { - return ""; - } - - if (typeId == VALUE_TYPE_BOOLEAN) { - return static_cast(AAFwk::IBoolean::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_BYTE) { - return static_cast(AAFwk::IByte::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_CHAR) { - return static_cast(AAFwk::IChar::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_SHORT) { - return static_cast(AAFwk::IShort::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_INT) { - return static_cast(AAFwk::IInteger::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_LONG) { - return static_cast(AAFwk::ILong::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_FLOAT) { - return static_cast(AAFwk::IFloat::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_DOUBLE) { - return static_cast(AAFwk::IDouble::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_STRING) { - return static_cast(AAFwk::IString::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_ARRAY) { - return static_cast(AAFwk::IArray::Query(iIt))->ToString(); - } else if (typeId == VALUE_TYPE_WANTPARAMS) { - return static_cast(IDistributedWantParams::Query(iIt))->ToString(); - } else { - return ""; + auto iter = interfaceQueryToStrMap.find(typeId); + if (iter != interfaceQueryToStrMap.end()) { + DistributedWantParams::InterfaceQueryToStrFunc &func = iter->second; + return (*func)(iIt); } return ""; } @@ -315,74 +474,13 @@ sptr DistributedWantParams::GetInterfaceByType(int typeId, const std return nullptr; } -bool DistributedWantParams::CompareNumberInterface(const sptr iIt1, - const sptr iIt2, int typeId) -{ - if (iIt1 == nullptr) { - return false; - } - bool flag = false; - switch (typeId) { - case VALUE_TYPE_SHORT: - flag = static_cast(AAFwk::IShort::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IShort::Query(iIt1)))); - break; - case VALUE_TYPE_INT: - flag = static_cast(AAFwk::IInteger::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IInteger::Query(iIt1)))); - break; - case VALUE_TYPE_LONG: - flag = static_cast(AAFwk::ILong::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::ILong::Query(iIt1)))); - break; - case VALUE_TYPE_FLOAT: - flag = static_cast(AAFwk::IFloat::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IFloat::Query(iIt1)))); - break; - case VALUE_TYPE_DOUBLE: - flag = static_cast(AAFwk::IDouble::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IDouble::Query(iIt1)))); - break; - default: - break; - } - return flag; -} - bool DistributedWantParams::CompareInterface(const sptr iIt1, const sptr iIt2, int typeId) { - if (iIt1 == nullptr) { - return false; - } bool flag = false; - switch (typeId) { - case VALUE_TYPE_BOOLEAN: - flag = static_cast(AAFwk::IBoolean::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IBoolean::Query(iIt1)))); - break; - case VALUE_TYPE_BYTE: - flag = static_cast(AAFwk::IByte::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IByte::Query(iIt1)))); - break; - case VALUE_TYPE_CHAR: - flag = static_cast(AAFwk::IChar::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IChar::Query(iIt1)))); - break; - case VALUE_TYPE_STRING: - flag = static_cast(AAFwk::IString::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IString::Query(iIt1)))); - break; - case VALUE_TYPE_ARRAY: - flag = static_cast(AAFwk::IArray::Query(iIt1)) - ->Equals(*(static_cast(AAFwk::IArray::Query(iIt1)))); - break; - case VALUE_TYPE_WANTPARAMS: - flag = static_cast(IDistributedWantParams::Query(iIt1)) - ->Equals(*(static_cast(IDistributedWantParams::Query(iIt1)))); - break; - default: - flag = CompareNumberInterface(iIt1, iIt2, typeId); - break; + auto iter = interfaceQueryEqualsMap.find(typeId); + if (iter != interfaceQueryEqualsMap.end()) { + DistributedWantParams::InterfaceQueryEqualsFunc &func = iter->second; + return (*func)(iIt1); } return flag; } @@ -475,11 +573,12 @@ bool DistributedWantParams::WriteToParcelWantParams(Parcel& parcel, sptr(IDistributedWantParams::Query(o)); + if (wantParams == nullptr) { return false; } - return parcel.WriteString16(Str8ToStr16( - static_cast(IDistributedWantParams::Query(o))->ToString())); + return parcel.WriteString16(Str8ToStr16(wantParams->ToString())); } bool DistributedWantParams::WriteToParcelFD(Parcel& parcel, const DistributedWantParams& value) const diff --git a/services/dtbschedmgr/src/distributed_sched_permission.cpp b/services/dtbschedmgr/src/distributed_sched_permission.cpp index 3db25d37..5204ec16 100644 --- a/services/dtbschedmgr/src/distributed_sched_permission.cpp +++ b/services/dtbschedmgr/src/distributed_sched_permission.cpp @@ -733,6 +733,9 @@ bool DistributedSchedPermission::CheckTargetAbilityVisible(const AppExecFwk::Abi void DistributedSchedPermission::RemoveRemoteObjectFromWant(std::shared_ptr want) const { + if (want == nullptr) { + return; + } WantParams wantParams = want->GetParams(); std::map> params = wantParams.GetParams(); for (auto param : params) { From 1f7b5bb2e123a7e7b3b46526437886dc3ee3ef42 Mon Sep 17 00:00:00 2001 From: Bobie Date: Wed, 28 Aug 2024 20:47:29 +0800 Subject: [PATCH 4/8] add template Signed-off-by: Bobie --- .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 51 +++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md index b2dcb188..7a44a95c 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -3,32 +3,31 @@ **描述**: **安全及低级编码自检:** -| 自检项 | 自检结果 | -| ------------------------------------------------------------------------------- | -------- | -| 变量使用前保证赋有效初值 | | -| 结构体预留字段也必须初始化为0,不允许出现随机值 | | -| 指针变量必须显示初始化为空 | | -| 涉及内存拷贝时合理校验目标内存大小,保证目标内存大于等于源内存 | | -| 进行字符串操作时,如字符串复制、申请字符串内存等,需要考虑字符串结束符 | | -| cJSON指针在异常分支里均需考虑内存释放(cJSON_free/cJSON_Delete),防止内存泄漏 | | -| 内存资源、文件句柄、管道资源、Socket句柄异常退出时要及时关闭 | | -| malloc申请内存后必须判断是否为空 | | -| 指针解引用或释放前判空(lamda表达式,异步任务等使用指针前需判空) | | -| 内存释放后立即置空,防止出现UAF | | -| 循环时容器的增、删、改操作,必须保证迭代器有效 | | -| 禁止将栈内存地址作为返回值或赋值给全局变量 | | -| 加法、乘法、减法操作,必须进行溢出和翻转保护,确保先校验再运算 | | -| 除法、求余操作必须进行除零保护 | | -| 循环变量用整型,禁止使用浮点型 | | -| 循环退出条件一定确保可达,防止出现死循环等问题 | | -| 不同大小结构体禁止强转 | | -| 禁止使用非安全函数,使用封装好的安全函数 | | -| 日志必须检查PassWord/位置信息/networkId/devId/uuid/udid等关键字,避免明文打印敏感信息 | | -| 对函数入参坚持先校验后使用的原则(指针判空、整型变量校验范围) | | -| 跨进程调用需注意权限校验,对外部传入的PID、tokenID进行权限校验 | | -| 共享数据均需加锁保护,并且锁配对使用 | | -| 条件变量正确加锁,消除条件变量唤醒丢失等问题 | | -| 加锁范围确保合理,避免过大或过小导致死锁问题 | | + +- [ ] 【变量初始化】变量使用前保证赋有效初值 +- [ ] 【变量初始化】结构体预留字段也必须初始化为0,不允许出现随机值 +- [ ] 【变量初始化】指针变量必须显示初始化为空 +- [ ] 【内存和资源】涉及内存拷贝时合理校验目标内存大小,保证目标内存大于等于源内存 +- [ ] 【内存和资源】进行字符串操作时,如字符串复制、申请字符串内存等,需要考虑字符串结束符 +- [ ] 【内存和资源】cJSON指针在异常分支里均需考虑内存释放(cJSON_free/cJSON_Delete),防止内存泄漏 +- [ ] 【内存和资源】内存资源、文件句柄、管道资源、Socket句柄异常退出时要及时关闭 +- [ ] 【指针】malloc申请内存后必须判断是否为空 +- [ ] 【指针】指针解引用或释放前判空(lamda表达式,异步任务等使用指针前需判空) +- [ ] 【指针】内存释放后立即置空,防止出现UAF +- [ ] 【指针】循环时容器的增、删、改操作,必须保证迭代器有效 +- [ ] 【指针】禁止将栈内存地址作为返回值或赋值给全局变量 +- [ ] 【数值边界】加法、乘法、减法操作,必须进行溢出和翻转保护,确保先校验再运算 +- [ ] 【数值边界】除法、求余操作必须进行除零保护 +- [ ] 【数值边界】循环变量用整型,禁止使用浮点型 +- [ ] 【数值边界】循环退出条件一定确保可达,防止出现死循环等问题 +- [ ] 【数值边界】不同大小结构体禁止强转 +- [ ] 【安全隐私】禁止使用非安全函数,使用封装好的安全函数 +- [ ] 【安全隐私】日志必须检查PassWord/位置信息/networkId/devId/uuid/udid等关键字,避免明文打印敏感信息 +- [ ] 【入参及权限校验】对函数入参坚持先校验后使用的原则(指针判空、整型变量校验范围) +- [ ] 【入参及权限校验】跨进程调用需注意权限校验,对外部传入的PID、tokenID进行权限校验 +- [ ] 【条件竞争】共享数据均需加锁保护,并且锁配对使用 +- [ ] 【条件竞争】条件变量正确加锁,消除条件变量唤醒丢失等问题 +- [ ] 【条件竞争】加锁范围确保合理,避免过大或过小导致死锁问题 **TDD结果**: From 86d0a639e04f3b43d2ed1223c4f48767b6318f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Wed, 28 Aug 2024 18:54:04 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfuzz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- services/dtbschedmgr/BUILD.gn | 3 +++ services/dtbschedmgr/src/distributed_sched_service.cpp | 3 +++ .../allconnectmgr/dsched_all_connect_manager.cpp | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/services/dtbschedmgr/BUILD.gn b/services/dtbschedmgr/BUILD.gn index 4a2a64e1..1620dd9b 100644 --- a/services/dtbschedmgr/BUILD.gn +++ b/services/dtbschedmgr/BUILD.gn @@ -62,6 +62,9 @@ config("distributed_sched_config") { if (dmsfwk_mmi_listener) { defines += [ "SUPPORT_MULTIMODALINPUT_SERVICE" ] } + if (use_libfuzzer || use_clang_coverage) { + defines += [ "TEST_COVERAGE" ] + } } ohos_shared_library("distributedschedsvr") { diff --git a/services/dtbschedmgr/src/distributed_sched_service.cpp b/services/dtbschedmgr/src/distributed_sched_service.cpp index 91d9ecf1..51f8d80c 100644 --- a/services/dtbschedmgr/src/distributed_sched_service.cpp +++ b/services/dtbschedmgr/src/distributed_sched_service.cpp @@ -1135,6 +1135,9 @@ int32_t DistributedSchedService::DealDSchedEventResult(const OHOS::AAFwk::Want& bool DistributedSchedService::GetIsFreeInstall(int32_t missionId) { + if (dschedContinuation_ == nullptr) { + return false; + } return dschedContinuation_->IsFreeInstall(missionId); } diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index a6569145..e2e43930 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -71,7 +71,9 @@ int32_t DSchedAllConnectManager::UninitAllConnectManager() if (ret != ERR_OK) { HILOGE("Unregist lifecycle callback fail, ret %{public}d.", ret); } +#ifndef TEST_COVERAGE dlclose(dllHandle_); +#endif dllHandle_ = nullptr; allConnectMgrApi_ = { .ServiceCollaborationManager_PublishServiceState = nullptr, @@ -125,7 +127,9 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy() if (ret != ERR_OK) { HILOGE("Get remote dms interactive adapter proxy fail, dlclose handle."); +#ifndef TEST_COVERAGE dlclose(dllHandle_); +#endif dllHandle_ = nullptr; } return ret; From 9ef3aaf40b1c417b8f6ab13aed711648f14aeadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Fri, 30 Aug 2024 07:00:28 +0000 Subject: [PATCH 6/8] update services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../allconnectmgr/dsched_all_connect_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index e2e43930..02a5bdfd 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -128,7 +128,7 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy() if (ret != ERR_OK) { HILOGE("Get remote dms interactive adapter proxy fail, dlclose handle."); #ifndef TEST_COVERAGE - dlclose(dllHandle_); + dlclose(dllHandle_) #endif dllHandle_ = nullptr; } From 2a7a81626cb05bcd89302e4692a9b0807fe86326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Fri, 30 Aug 2024 07:43:46 +0000 Subject: [PATCH 7/8] update services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../allconnectmgr/dsched_all_connect_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index 02a5bdfd..e2e43930 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -128,7 +128,7 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy() if (ret != ERR_OK) { HILOGE("Get remote dms interactive adapter proxy fail, dlclose handle."); #ifndef TEST_COVERAGE - dlclose(dllHandle_) + dlclose(dllHandle_); #endif dllHandle_ = nullptr; } From 6dd82f14c9a7b1a6e44dc57fb3a2c992bbacbc6e Mon Sep 17 00:00:00 2001 From: c30051536 Date: Sat, 31 Aug 2024 11:26:10 +0800 Subject: [PATCH 8/8] remove unfocus check Signed-off-by: c30051536 --- .../src/mission/dms_continue_send_manager.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index 51dc3528..8629651c 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -385,8 +385,7 @@ int32_t DMSContinueSendMgr::DealUnfocusedBusiness(const int32_t missionId, Unfoc return ret; } if (reason != UnfocusedReason::TIMEOUT) { - bool isContinue = IsContinue(missionId, bundleName); - if (!isContinue) { + if (!IsContinue(missionId, bundleName)) { HILOGE("Not current mission to be continued, missionId: %{public}d", missionId); EraseFocusedMission(bundleName, missionId, reason); return NO_MISSION_INFO_FOR_MISSION_ID; @@ -395,13 +394,6 @@ int32_t DMSContinueSendMgr::DealUnfocusedBusiness(const int32_t missionId, Unfoc RemoveMMIListener(); #endif } - ret = CheckContinueState(missionId); - if (ret != ERR_OK) { - HILOGE("Continue state is inactive or can't be obtained, mission id : %{public}d, ret: %{public}d", - missionId, ret); - EraseFocusedMission(bundleName, missionId, reason); - return ret; - } uint16_t bundleNameId = 0; uint8_t continueTypeId = 0; ret = GetAccessTokenIdSendEvent(bundleName, reason, bundleNameId, continueTypeId);