From 330be41656881ad0820efaf66690cd7bcea0f149 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Mon, 29 Jul 2024 11:20:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../include/deviceprofile_connector.h | 1 + .../src/deviceprofile_connector.cpp | 16 ++++++++ .../include/authentication/dm_auth_manager.h | 1 + .../dependency/hichain/hichain_connector.h | 1 + .../include/device_manager_service_impl.h | 1 + .../device_manager_service_impl_lite.h | 1 + .../src/authentication/dm_auth_manager.cpp | 11 ++++++ .../dependency/hichain/hichain_connector.cpp | 18 +++++++++ .../src/device_manager_service_impl.cpp | 10 +++++ .../src/device_manager_service_impl_lite.cpp | 6 +++ .../service/include/device_manager_service.h | 1 + .../service/include/i_dm_service_impl_ext.h | 6 +++ .../include/idevice_manager_service_impl.h | 5 ++- .../include/softbus/softbus_listener.h | 2 + .../service/src/device_manager_service.cpp | 30 +++++++++++++++ .../service/src/softbus/softbus_listener.cpp | 38 ++++++++++++++++--- 16 files changed, 140 insertions(+), 8 deletions(-) diff --git a/commondependency/include/deviceprofile_connector.h b/commondependency/include/deviceprofile_connector.h index e2e04c112..d60e259cf 100644 --- a/commondependency/include/deviceprofile_connector.h +++ b/commondependency/include/deviceprofile_connector.h @@ -149,6 +149,7 @@ public: const DmAccessCallee &callee, const std::string &sinkUdid); int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); + void DeleteAccessControlList(const std::string &udid); private: int32_t HandleDmAuthForm(DistributedDeviceProfile::AccessControlProfile profiles, DmDiscoveryInfo discoveryInfo); diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index 956ec72ad..60dde1581 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -456,6 +456,22 @@ int32_t DeviceProfileConnector::DeleteAccessControlList(int32_t userId, std::str return DM_OK; } +void DeviceProfileConnector::DeleteAccessControlList(const std::string &udid) +{ + LOGI("DeleteAccessControlList by udid: %{public}s.", GetAnonyString(udid).c_str()); + if (udid.empty()) { + LOGE("DeleteAccessControlList udid is empty."); + return; + } + std::vector profiles = GetAccessControlProfile(); + LOGI("AccessControlProfile size is %{public}zu", profiles.size()); + for (const auto &item : profiles) { + if (item.GetTrustDeviceId() == udid) { + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + } + } +} + DmOfflineParam DeviceProfileConnector::DeleteAccessControlList(std::string pkgName, std::string localDeviceId, std::string remoteDeviceId) { diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 78f2e133a..4ae25cbd3 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -523,6 +523,7 @@ public: void BindSocketSuccess(int32_t socket); void BindSocketFail(); void OnScreenLocked(); + void HandleDeviceNotTrust(const std::string &udid); private: int32_t ImportCredential(std::string &deviceId, std::string &publicKey); void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, diff --git a/services/implementation/include/dependency/hichain/hichain_connector.h b/services/implementation/include/dependency/hichain/hichain_connector.h index 67c6e3cb8..c4e0e2df6 100644 --- a/services/implementation/include/dependency/hichain/hichain_connector.h +++ b/services/implementation/include/dependency/hichain/hichain_connector.h @@ -237,6 +237,7 @@ public: int32_t GetRelatedGroupsCommon(const std::string &deviceId, const char* pkgName, std::vector &groupList); + void DeleteAllGroupByUdid(const std::string &udid); private: int64_t GenRequestId(); int32_t SyncGroups(std::string deviceId, std::vector &remoteGroupIdList); diff --git a/services/implementation/include/device_manager_service_impl.h b/services/implementation/include/device_manager_service_impl.h index 64e7ed662..09d1fe4ea 100644 --- a/services/implementation/include/device_manager_service_impl.h +++ b/services/implementation/include/device_manager_service_impl.h @@ -135,6 +135,7 @@ public: const DmAccessCallee &callee, const std::string &sinkUdid); int32_t CheckAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); + void HandleDeviceNotTrust(const std::string &udid); private: int32_t PraseNotifyEventJson(const std::string &event, nlohmann::json &jsonObject); std::string GetUdidHashByNetworkId(const std::string &networkId); diff --git a/services/implementation/include/device_manager_service_impl_lite.h b/services/implementation/include/device_manager_service_impl_lite.h index a6dde1eb4..b7c7de380 100644 --- a/services/implementation/include/device_manager_service_impl_lite.h +++ b/services/implementation/include/device_manager_service_impl_lite.h @@ -134,6 +134,7 @@ public: const DmAccessCallee &callee, const std::string &sinkUdid); int32_t CheckAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); + void HandleDeviceNotTrust(const std::string &udid); private: std::string GetUdidHashByNetworkId(const std::string &networkId); diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index a494f2150..fc3e6aa17 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2525,5 +2525,16 @@ void DmAuthManager::OnScreenLocked() SetReasonAndFinish(ERR_DM_BIND_USER_CANCEL, STATUS_DM_AUTH_DEFAULT); } } + +void DmAuthManager::HandleDeviceNotTrust(const std::string &udid) +{ + LOGI("DmAuthManager::HandleDeviceNotTrust udid: %{public}s.", GetAnonyString(udid).c_str()); + if (udid.empty()) { + LOGE("DmAuthManager::HandleDeviceNotTrust udid is empty."); + return; + } + DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid); + hiChainConnector_->DeleteAllGroupByUdid(udid); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index 7e84eefe3..4721bd730 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -1208,5 +1208,23 @@ int32_t HiChainConnector::GetRelatedGroupsCommon(const std::string &deviceId, co return DM_OK; } +void HiChainConnector::DeleteAllGroupByUdid(const std::string &udid) +{ + LOGI("HiChainConnector::DeleteAllGroupByUdid %{public}s.", GetAnonyString(udid).c_str()); + std::vector groupList; + GetRelatedGroups(udid, groupList); + for (auto &iter : groupList) { + if (DeleteGroup(iter.groupId) != DM_OK) { + LOGE("Delete groupId %{public}s failed.", GetAnonyString(iter.groupId).c_str()); + } + } + std::vector groupListExt; + GetRelatedGroupsExt(udid, groupListExt); + for (auto &iter : groupListExt) { + if (DeleteGroupExt(iter.groupId) != DM_OK) { + LOGE("DeleteGroupExt groupId %{public}s failed.", GetAnonyString(iter.groupId).c_str()); + } + } +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index ec01d2d95..0d0c9b86f 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -713,6 +713,16 @@ int32_t DeviceManagerServiceImpl::CheckAccessControl(const DmAccessCaller &calle return DeviceProfileConnector::GetInstance().CheckAccessControl(caller, srcUdid, callee, sinkUdid); } +void DeviceManagerServiceImpl::HandleDeviceNotTrust(const std::string &udid) +{ + LOGI("DeviceManagerServiceImpl::HandleDeviceNotTrust udid: %{public}s.", GetAnonyString(udid).c_str()); + if (udid.empty()) { + LOGE("HandleDeviceNotTrust udid is empty."); + return; + } + authMgr_->HandleDeviceNotTrust(udid); +} + extern "C" IDeviceManagerServiceImpl *CreateDMServiceObject(void) { return new DeviceManagerServiceImpl; diff --git a/services/implementation/src/device_manager_service_impl_lite.cpp b/services/implementation/src/device_manager_service_impl_lite.cpp index eadb8ac68..2864f44b7 100644 --- a/services/implementation/src/device_manager_service_impl_lite.cpp +++ b/services/implementation/src/device_manager_service_impl_lite.cpp @@ -481,6 +481,12 @@ int32_t DeviceManagerServiceImpl::CheckAccessControl(const DmAccessCaller &calle return DM_OK; } +void DeviceManagerServiceImpl::HandleDeviceNotTrust(const std::string &udid) +{ + (void)udid; + return; +} + extern "C" IDeviceManagerServiceImpl *CreateDMServiceObject(void) { return new DeviceManagerServiceImpl; diff --git a/services/service/include/device_manager_service.h b/services/service/include/device_manager_service.h index b3018a15c..6e2e24356 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -192,6 +192,7 @@ public: int32_t InitScreenLockEvent(); bool CheckAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee); bool CheckIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee); + void HandleDeviceNotTrust(const std::string &msg); private: bool IsDMServiceImplReady(); diff --git a/services/service/include/i_dm_service_impl_ext.h b/services/service/include/i_dm_service_impl_ext.h index b4655ff30..cb30d1dea 100644 --- a/services/service/include/i_dm_service_impl_ext.h +++ b/services/service/include/i_dm_service_impl_ext.h @@ -79,6 +79,12 @@ public: * @tc.type: FUNC */ virtual int32_t AccountIdLogout(int32_t userId, const std::string &oldAccountId) = 0; + /** + * @tc.name: IDMServiceImplExt::HandleDeviceNotTrust + * @tc.desc: HandleDeviceNotTrust + * @tc.type: FUNC + */ + virtual void HandleDeviceNotTrust(const std::string &udid) = 0; }; using CreateDMServiceImplExtFuncPtr = IDMServiceImplExt *(*)(void); diff --git a/services/service/include/idevice_manager_service_impl.h b/services/service/include/idevice_manager_service_impl.h index 415eb0403..d0d06323a 100644 --- a/services/service/include/idevice_manager_service_impl.h +++ b/services/service/include/idevice_manager_service_impl.h @@ -278,9 +278,10 @@ public: virtual void AccountCommonEventCallback(int32_t userId, std::string commonEventType) = 0; virtual void ScreenCommonEventCallback(std::string commonEventType) = 0; virtual int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, - const DmAccessCallee &callee, const std::string &sinkUdid); + const DmAccessCallee &callee, const std::string &sinkUdid) = 0; virtual int32_t CheckAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, - const DmAccessCallee &callee, const std::string &sinkUdid); + const DmAccessCallee &callee, const std::string &sinkUdid) = 0; + virtual void HandleDeviceNotTrust(const std::string &udid) = 0; }; using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void); diff --git a/services/service/include/softbus/softbus_listener.h b/services/service/include/softbus/softbus_listener.h index 0c5a2ef66..362e132ce 100644 --- a/services/service/include/softbus/softbus_listener.h +++ b/services/service/include/softbus/softbus_listener.h @@ -53,6 +53,8 @@ public: static void DeviceOffLine(DmDeviceInfo deviceInfo); static void DeviceNameChange(DmDeviceInfo deviceInfo); static void OnLocalDevInfoChange(); + static void OnDeviceNotTrusted(const char *msg); + static void DeviceNotTrust(const std::string &msg); static void CacheDiscoveredDevice(const DeviceInfo *device); static void ClearDiscoveredDevice(); diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 6cec07d82..6cfec1869 100755 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -61,6 +61,7 @@ const int32_t NORMAL = 0; const int32_t SYSTEM_BASIC = 1; const int32_t SYSTEM_CORE = 2; constexpr const char* ALL_PKGNAME = ""; +constexpr const char* NETWORKID = "NETWORK_ID"; DeviceManagerService::~DeviceManagerService() { LOGI("DeviceManagerService destructor"); @@ -1604,5 +1605,34 @@ void DeviceManagerService::ScreenCommonEventCallback(std::string commonEventType } #endif +void DeviceManagerService::HandleDeviceNotTrust(const std::string &msg) +{ + LOGI("DeviceManagerService::HandleDeviceNotTrust."); + if (msg.empty()) { + LOGE("DeviceManagerService::HandleDeviceNotTrust msg is empty."); + return; + } + nlohmann::json msgJsonObj = nlohmann::json::parse(msg, nullptr, false); + if (msgJsonObj.is_discarded()) { + LOGE("HandleDeviceNotTrust msg prase error."); + return; + } + if (!IsString(msgJsonObj, NETWORKID)) { + LOGE("HandleDeviceNotTrust msg not contain networkId."); + return; + } + std::string networkId = msgJsonObj[NETWORKID].get(); + std::string udid = ""; + SoftbusCache::GetInstance().GetUdidFromCache(networkId.c_str(), udid); + LOGI("HandleDeviceNotTrust networkId: %{public}s, udid: %{public}s.", + GetAnonyString(networkId).c_str(), GetAnonyString(udid).c_str()); + if (IsDMImplSoLoaded()) { + dmServiceImpl_->HandleDeviceNotTrust(udid); + } + if (IsDMServiceImplReady()) { + dmServiceImplExt_->HandleDeviceNotTrust(udid); + } + return; +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index bc58d2f1d..26b5b2885 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -43,6 +43,7 @@ constexpr const char* DEVICE_ONLINE = "deviceOnLine"; constexpr const char* DEVICE_OFFLINE = "deviceOffLine"; constexpr const char* DEVICE_NAME_CHANGE = "deviceNameChange"; constexpr const char* LIB_RADAR_NAME = "libdevicemanagerradar.z.so"; +constexpr const char* DEVICE_NOT_TRUST = "deviceNotTrust"; constexpr static char HEX_ARRAY[] = "0123456789ABCDEF"; constexpr static uint8_t BYTE_MASK = 0x0F; constexpr static uint16_t ARRAY_DOUBLE_SIZE = 2; @@ -52,6 +53,10 @@ static std::mutex g_deviceMapMutex; static std::mutex g_lnnCbkMapMutex; static std::mutex g_radarLoadLock; static std::mutex g_onlineDeviceNumLock; +static std::mutex g_lockDeviceNotTrust; +static std::mutex g_lockDeviceOnLine; +static std::mutex g_lockDeviceOffLine; +static std::mutex g_lockDevInfoChange; static std::map>>> discoveredDeviceMap; static std::map> lnnOpsCbkMap; @@ -113,6 +118,7 @@ static INodeStateCb softbusNodeStateCb_ = { .onNodeOffline = SoftbusListener::OnSoftbusDeviceOffline, .onNodeBasicInfoChanged = SoftbusListener::OnSoftbusDeviceInfoChanged, .onLocalNetworkIdChanged = SoftbusListener::OnLocalDevInfoChange, + .onNodeDeviceNotTrusted = SoftbusListener::OnDeviceNotTrusted, }; static IRefreshCallback softbusRefreshCallback_ = { @@ -122,25 +128,28 @@ static IRefreshCallback softbusRefreshCallback_ = { void SoftbusListener::DeviceOnLine(DmDeviceInfo deviceInfo) { - std::mutex lockDeviceOnLine; - std::lock_guard lock(lockDeviceOnLine); + std::lock_guard lock(g_lockDeviceOnLine); DeviceManagerService::GetInstance().HandleDeviceStatusChange(DEVICE_STATE_ONLINE, deviceInfo); } void SoftbusListener::DeviceOffLine(DmDeviceInfo deviceInfo) { - std::mutex lockDeviceOffLine; - std::lock_guard lock(lockDeviceOffLine); + std::lock_guard lock(g_lockDeviceOffLine); DeviceManagerService::GetInstance().HandleDeviceStatusChange(DEVICE_STATE_OFFLINE, deviceInfo); } void SoftbusListener::DeviceNameChange(DmDeviceInfo deviceInfo) { - std::mutex lockDeviceOffLine; - std::lock_guard lock(lockDeviceOffLine); + std::lock_guard lock(g_lockDevInfoChange); DeviceManagerService::GetInstance().HandleDeviceStatusChange(DEVICE_INFO_CHANGED, deviceInfo); } +void SoftbusListener::DeviceNotTrust(const std::string &msg) +{ + std::lock_guard lock(g_lockDeviceNotTrust); + DeviceManagerService::GetInstance().HandleDeviceNotTrust(msg); +} + void SoftbusListener::OnSoftbusDeviceOnline(NodeBasicInfo *info) { LOGI("received device online callback from softbus."); @@ -269,6 +278,23 @@ void SoftbusListener::OnLocalDevInfoChange() SoftbusCache::GetInstance().UpDataLocalDevInfo(); } +void SoftbusListener::OnDeviceNotTrusted(const char *msg) +{ + LOGI("SoftbusListener::OnDeviceNotTrusted."); + + if (msg == nullptr) { + LOGE("OnDeviceNotTrusted msg is nullptr."); + return; + } + std::string softbusMsg = std::string(msg); + std::thread deviceNotTrust([=]() { DeviceNotTrust(softbusMsg); }); + int32_t ret = pthread_setname_np(deviceNotTrust.native_handle(), DEVICE_NOT_TRUST); + if (ret != DM_OK) { + LOGE("deviceNotTrust setname failed."); + } + deviceNotTrust.detach(); +} + void SoftbusListener::OnSoftbusDeviceFound(const DeviceInfo *device) { if (device == nullptr) { -- Gitee From c701d68afc020e27728d245c3ee96246f552c6b3 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 30 Jul 2024 22:19:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../implementation/src/authentication/dm_auth_manager.cpp | 4 +++- services/implementation/src/device_manager_service_impl.cpp | 3 +++ services/service/src/softbus/softbus_listener.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index fc3e6aa17..a9018624a 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2534,7 +2534,9 @@ void DmAuthManager::HandleDeviceNotTrust(const std::string &udid) return; } DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid); - hiChainConnector_->DeleteAllGroupByUdid(udid); + if (hiChainConnector_ != nullptr) { + hiChainConnector_->DeleteAllGroupByUdid(udid); + } } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 0d0c9b86f..70c547963 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -683,6 +683,7 @@ void DeviceManagerServiceImpl::AccountCommonEventCallback(int32_t userId, std::s { if (commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED || commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT) { + CHECK_NULL_VOID(authMgr_); authMgr_->CommonEventCallback(userId, commonEventType); LOGI("DeviceManagerServiceImpl::account event: %{public}s, userId: %{public}s", commonEventType.c_str(), GetAnonyInt32(userId).c_str()); @@ -695,6 +696,7 @@ void DeviceManagerServiceImpl::ScreenCommonEventCallback(std::string commonEvent { if (commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED) { LOGI("DeviceManagerServiceImpl::ScreenCommonEventCallback on screen locked."); + CHECK_NULL_VOID(authMgr_); authMgr_->OnScreenLocked(); return; } @@ -720,6 +722,7 @@ void DeviceManagerServiceImpl::HandleDeviceNotTrust(const std::string &udid) LOGE("HandleDeviceNotTrust udid is empty."); return; } + CHECK_NULL_RETURN(authMgr_, ERR_DM_POINT_NULL); authMgr_->HandleDeviceNotTrust(udid); } diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index 26b5b2885..95503e06c 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -39,6 +39,7 @@ namespace DistributedHardware { const int32_t SOFTBUS_CHECK_INTERVAL = 100000; // 100ms const int32_t SOFTBUS_SUBSCRIBE_ID_MASK = 0x0000FFFF; const int32_t MAX_CACHED_DISCOVERED_DEVICE_SIZE = 100; +const int32_t MAX_SOFTBUS_MSG_LEN = 2000; constexpr const char* DEVICE_ONLINE = "deviceOnLine"; constexpr const char* DEVICE_OFFLINE = "deviceOffLine"; constexpr const char* DEVICE_NAME_CHANGE = "deviceNameChange"; -- Gitee From 385989fc2016fd4456e5fa4249e102010ed8153a Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 30 Jul 2024 22:20:41 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/implementation/src/device_manager_service_impl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 70c547963..233ca3978 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -683,7 +683,6 @@ void DeviceManagerServiceImpl::AccountCommonEventCallback(int32_t userId, std::s { if (commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED || commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT) { - CHECK_NULL_VOID(authMgr_); authMgr_->CommonEventCallback(userId, commonEventType); LOGI("DeviceManagerServiceImpl::account event: %{public}s, userId: %{public}s", commonEventType.c_str(), GetAnonyInt32(userId).c_str()); @@ -696,7 +695,6 @@ void DeviceManagerServiceImpl::ScreenCommonEventCallback(std::string commonEvent { if (commonEventType == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED) { LOGI("DeviceManagerServiceImpl::ScreenCommonEventCallback on screen locked."); - CHECK_NULL_VOID(authMgr_); authMgr_->OnScreenLocked(); return; } -- Gitee From a9c49658d7774b7a52e4776aa71f0acdd2b2b6eb Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 30 Jul 2024 22:29:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/service/src/softbus/softbus_listener.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index 95503e06c..878f5596e 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -283,8 +283,8 @@ void SoftbusListener::OnDeviceNotTrusted(const char *msg) { LOGI("SoftbusListener::OnDeviceNotTrusted."); - if (msg == nullptr) { - LOGE("OnDeviceNotTrusted msg is nullptr."); + if (msg == nullptr || strlen(msg) > MAX_SOFTBUS_MSG_LEN) { + LOGE("OnDeviceNotTrusted msg invalied."); return; } std::string softbusMsg = std::string(msg); -- Gitee From 9fbe18b4fd2e9318e57d6434a713c4c217ca9ae2 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 30 Jul 2024 22:32:37 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../implementation/src/authentication/dm_auth_manager.cpp | 5 ++--- services/implementation/src/device_manager_service_impl.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index a9018624a..d2221fc04 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2534,9 +2534,8 @@ void DmAuthManager::HandleDeviceNotTrust(const std::string &udid) return; } DeviceProfileConnector::GetInstance().DeleteAccessControlList(udid); - if (hiChainConnector_ != nullptr) { - hiChainConnector_->DeleteAllGroupByUdid(udid); - } + CHECK_NULL_VOID(hiChainConnector_); + hiChainConnector_->DeleteAllGroupByUdid(udid); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 233ca3978..b27b42df7 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -720,7 +720,7 @@ void DeviceManagerServiceImpl::HandleDeviceNotTrust(const std::string &udid) LOGE("HandleDeviceNotTrust udid is empty."); return; } - CHECK_NULL_RETURN(authMgr_, ERR_DM_POINT_NULL); + CHECK_NULL_VOID(authMgr_); authMgr_->HandleDeviceNotTrust(udid); } -- Gitee