From 5f570571682adeda8e38ad41d7684948afb53261 Mon Sep 17 00:00:00 2001 From: lee Date: Fri, 3 Nov 2023 21:12:03 +0800 Subject: [PATCH] fix sec issue Signed-off-by: lee --- frameworks/inner/c_adapter/ohos_bt_gatt.cpp | 3 ++- frameworks/inner/src/bluetooth_remote_device.cpp | 4 ++++ frameworks/inner/src/bluetooth_socket.cpp | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frameworks/inner/c_adapter/ohos_bt_gatt.cpp b/frameworks/inner/c_adapter/ohos_bt_gatt.cpp index a4453361..9925d6e5 100644 --- a/frameworks/inner/c_adapter/ohos_bt_gatt.cpp +++ b/frameworks/inner/c_adapter/ohos_bt_gatt.cpp @@ -94,7 +94,8 @@ public: } strStream >> strs; string address = result.GetPeripheralDevice().GetDeviceAddr(); - HILOGD("device: %{public}s, scan data: %{public}s", GetEncryptAddr(address).c_str(), strs.c_str()); + HILOGD("device: %{public}s, len: %{public}d, scan data: %{public}s", + GetEncryptAddr(address).c_str(), scanResult.advLen, strs.c_str()); if (appCallback != nullptr && appCallback->scanResultCb != nullptr) { appCallback->scanResultCb(&scanResult); } else { diff --git a/frameworks/inner/src/bluetooth_remote_device.cpp b/frameworks/inner/src/bluetooth_remote_device.cpp index 88a36c0d..bc6ba99c 100644 --- a/frameworks/inner/src/bluetooth_remote_device.cpp +++ b/frameworks/inner/src/bluetooth_remote_device.cpp @@ -30,6 +30,10 @@ namespace Bluetooth { sptr GetHostProxy() { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!samgr) { + HILOGE("samgr is nullptr."); + return nullptr; + } sptr remote = samgr->GetSystemAbility(BLUETOOTH_HOST_SYS_ABILITY_ID); sptr hostProxy = new BluetoothHostProxy(remote); diff --git a/frameworks/inner/src/bluetooth_socket.cpp b/frameworks/inner/src/bluetooth_socket.cpp index 31bb8d56..f92a830b 100644 --- a/frameworks/inner/src/bluetooth_socket.cpp +++ b/frameworks/inner/src/bluetooth_socket.cpp @@ -256,6 +256,10 @@ ClientSocket::impl::impl(const BluetoothRemoteDevice &addr, UUID uuid, BtSocketT { HILOGD("enter"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!samgr) { + HILOGE("samgr is nullptr."); + return; + } sptr hostRemote = samgr->GetSystemAbility(BLUETOOTH_HOST_SYS_ABILITY_ID); if (!hostRemote) { @@ -297,6 +301,10 @@ ClientSocket::impl::impl(int fd, std::string address, BtSocketType type) { HILOGD("enter"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!samgr) { + HILOGE("samgr is nullptr."); + return; + } sptr hostRemote = samgr->GetSystemAbility(BLUETOOTH_HOST_SYS_ABILITY_ID); if (!hostRemote) { @@ -720,6 +728,10 @@ ServerSocket::impl::impl(const std::string &name, UUID uuid, BtSocketType type, { HILOGI("(4 parameters) starts"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!samgr) { + HILOGE("samgr is nullptr."); + return; + } sptr hostRemote = samgr->GetSystemAbility(BLUETOOTH_HOST_SYS_ABILITY_ID); if (!hostRemote) { -- Gitee