From d721f3482717ecc796aed1c00ede1b0dad605309 Mon Sep 17 00:00:00 2001 From: libo429 Date: Wed, 30 Jul 2025 09:40:01 +0800 Subject: [PATCH] =?UTF-8?q?FUZZ=20crash=E5=A4=B1=E8=B4=A5=E4=B8=8EAI?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81=E5=9B=9E=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: libo429 --- .../native_cpp/src/notify/device_manager_notify.cpp | 4 ++-- interfaces/kits/js/src/native_devicemanager_js.cpp | 2 ++ interfaces/kits/js4.0/src/native_devicemanager_js.cpp | 2 ++ utils/BUILD.gn | 3 --- utils/src/appInfo/standard/app_manager.cpp | 4 +++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 8e276a232..c381afc67 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -107,7 +107,7 @@ void DeviceManagerNotify::RegisterDeviceStatusCallback(const std::string &pkgNam } std::lock_guard autoLock(lock_); if (deviceStatusCallback_.size() >= MAX_CONTAINER_SIZE) { - LOGE("deviceStateCallback_ map size is more than max size"); + LOGE("deviceStatusCallback_ map size is more than max size"); return; } deviceStatusCallback_[pkgName] = callback; @@ -191,7 +191,7 @@ void DeviceManagerNotify::RegisterAuthenticateCallback(const std::string &pkgNam std::lock_guard autoLock(lock_); if (authenticateCallback_.count(pkgName) == 0) { if (authenticateCallback_.size() >= MAX_CONTAINER_SIZE) { - LOGE("devicePublishCallbacks_ map size is more than max size"); + LOGE("authenticateCallback_ map size is more than max size"); return; } authenticateCallback_[pkgName] = std::map>(); diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index bfdd9d669..df954de30 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -3291,6 +3291,8 @@ napi_value DeviceManagerNapi::Constructor(napi_env env, napi_callback_info info) std::lock_guard autoLock(g_deviceManagerMapMutex); if (g_deviceManagerMap.size() >= MAX_CONTAINER_SIZE) { LOGE("g_deviceManagerMap map size is more than max size"); + delete obj; + obj = nullptr; return nullptr; } g_deviceManagerMap[obj->bundleName_] = obj; diff --git a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp index 7b2458277..a7894642a 100644 --- a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp @@ -2853,6 +2853,8 @@ napi_value DeviceManagerNapi::Constructor(napi_env env, napi_callback_info info) std::lock_guard autoLock(g_deviceManagerMapMutex); if (g_deviceManagerMap.size() >= MAX_CONTAINER_SIZE) { LOGE("g_deviceManagerMap map size is more than max size"); + delete obj; + obj = nullptr; return nullptr; } g_deviceManagerMap[obj->bundleName_] = obj; diff --git a/utils/BUILD.gn b/utils/BUILD.gn index b533b2e49..c4d1ba8fe 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -46,7 +46,6 @@ if (defined(ohos_lite)) { "${common_path}/src/dfx/lite/dm_hisysevent.cpp", "${common_path}/src/dfx/lite/dm_hitrace.cpp", "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "${common_path}/src/dm_error_message.cpp", "${common_path}/src/ipc/lite/ipc_cmd_register.cpp", "src/appInfo/lite/app_manager.cpp", @@ -129,7 +128,6 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", @@ -210,7 +208,6 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.cpp", - "${common_path}/src/dm_constants.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", diff --git a/utils/src/appInfo/standard/app_manager.cpp b/utils/src/appInfo/standard/app_manager.cpp index 42cf4b60a..b9537ca5f 100644 --- a/utils/src/appInfo/standard/app_manager.cpp +++ b/utils/src/appInfo/standard/app_manager.cpp @@ -24,7 +24,6 @@ #include "system_ability_definition.h" #include "tokenid_kit.h" -#include "dm_constants.h" #include "dm_anonymous.h" #include "dm_error_type.h" #include "dm_log.h" @@ -33,6 +32,9 @@ using namespace OHOS::Security::AccessToken; namespace OHOS { namespace DistributedHardware { +namespace { +const int32_t MAX_CONTAINER_SIZE = 1000; +} DM_IMPLEMENT_SINGLE_INSTANCE(AppManager); const std::string AppManager::GetAppId() -- Gitee