From 679f892ef65839ba7223a2fe201fb3e746b93f2a Mon Sep 17 00:00:00 2001 From: hmilylmk Date: Fri, 16 Dec 2022 14:10:17 +0800 Subject: [PATCH] dsoftbus: change pkgname's judgment conditions in addservice func * In the judgment conditions of other functions, an empty string of pkgname is considered a valid parameter. But in addservice is invalid, so change its judgment condition to be consistent with others. Signed-off-by: hmilylmk --- .../client_manager/src/softbus_client_info_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp b/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp index 987ecc62..66faa5ba 100644 --- a/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp +++ b/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp @@ -17,6 +17,7 @@ #include "softbus_errcode.h" #include "softbus_log.h" +#include "softbus_def.h" // for pkgname bounds check. namespace OHOS { SoftbusClientInfoManager &SoftbusClientInfoManager::GetInstance() @@ -28,8 +29,8 @@ SoftbusClientInfoManager &SoftbusClientInfoManager::GetInstance() int32_t SoftbusClientInfoManager::SoftbusAddService(const std::string &pkgName, const sptr &object, const sptr &abilityDeath) { - if (pkgName.empty() || object == nullptr || abilityDeath == nullptr) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "package name, object or abilityDeath is nullptr\n"); + if (pkgName.size() >= PKG_NAME_SIZE_MAX || object == nullptr || abilityDeath == nullptr) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "pkgName is too long, or object, abilityDeath is nullptr\n"); return SOFTBUS_ERR; } std::lock_guard autoLock(clientObjectMapLock_); -- Gitee