From c50ece4f32da6d6ad0a55f8b7522cef67a370b95 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 7 Apr 2025 15:48:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- frameworks/ans/src/notification_icon_button.cpp | 2 +- .../ans/src/notification_local_live_view_button.cpp | 2 +- .../ans/src/advanced_notification_publish_service.cpp | 8 ++++++++ services/ans/src/notification_preferences.cpp | 4 ++++ .../src/soft_bus/distributed_publish_service.cpp | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frameworks/ans/src/notification_icon_button.cpp b/frameworks/ans/src/notification_icon_button.cpp index 3a8a9db73..0c799fc43 100644 --- a/frameworks/ans/src/notification_icon_button.cpp +++ b/frameworks/ans/src/notification_icon_button.cpp @@ -311,7 +311,7 @@ bool NotificationIconButton::ReadResourceFromParcel(Parcel &parcel, ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); resourceObj = resource; return true; } diff --git a/frameworks/ans/src/notification_local_live_view_button.cpp b/frameworks/ans/src/notification_local_live_view_button.cpp index 2b96fc2b3..31fbce667 100644 --- a/frameworks/ans/src/notification_local_live_view_button.cpp +++ b/frameworks/ans/src/notification_local_live_view_button.cpp @@ -272,7 +272,7 @@ bool NotificationLocalLiveViewButton::ReadFromParcel(Parcel &parcel) ANS_LOGE("Invalid input for button icons resource"); return false; } - resource->id = std::stoi(iconsResource[RESOURCE_ID_INDEX]); + resource->id = atoi(iconsResource[RESOURCE_ID_INDEX].c_str()); buttonIconsResource_.emplace_back(resource); } diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 3238874c3..4753a881f 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -523,6 +523,14 @@ ErrCode AdvancedNotificationService::CancelAsBundle( { ANS_LOGD("%{public}s", __FUNCTION__); int32_t reason = NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE; + if (bundleOption == nullptr) { + std::string message = "bundleOption is invalid"; + OHOS::Notification::HaMetaMessage haMetaMessage = HaMetaMessage(2, 0) + .ErrorCode(ERR_ANS_INVALID_PARAM).NotificationId(notificationId); + ReportDeleteFailedEventPush(haMetaMessage, reason, message); + ANS_LOGE("%{public}s", message.c_str()); + return ERR_ANS_INVALID_PARAM; + } bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { std::string message = "not systemApp"; diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index cbd846d8b..b4006a887 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -634,6 +634,10 @@ ErrCode NotificationPreferences::UpdateDoNotDisturbProfiles(int32_t userId, int6 } sptr profile = new (std::nothrow) NotificationDoNotDisturbProfile(); + if (profile == nullptr) { + ANS_LOGE("profile is nullptr"); + return ERR_ANS_INVALID_PARAM; + } std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (preferencesInfo.GetDoNotDisturbProfiles(profileId, userId, profile)) { diff --git a/services/distributed/src/soft_bus/distributed_publish_service.cpp b/services/distributed/src/soft_bus/distributed_publish_service.cpp index 6b685d87d..f30b82b65 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service.cpp @@ -349,7 +349,7 @@ void DistributedService::RemoveNotifications(const std::shared_ptr& boxM std::string slotTypeString; while (slotTypesStream >> slotTypeString) { if (!slotTypeString.empty()) { - OperationalReporting(OPERATION_DELETE_BRANCH, std::stoi(slotTypeString)); + OperationalReporting(OPERATION_DELETE_BRANCH, atoi(slotTypeString.c_str())); } } } else { -- Gitee From 0bfcc3e2fb7da80df3562875460c22983fe85a57 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Mon, 7 Apr 2025 19:47:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=A3=8E?= =?UTF-8?q?=E9=99=A9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- frameworks/js/napi/src/subscribe/napi_subscribe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp index deb0ceec8..15eaa9009 100644 --- a/frameworks/js/napi/src/subscribe/napi_subscribe.cpp +++ b/frameworks/js/napi/src/subscribe/napi_subscribe.cpp @@ -40,6 +40,10 @@ void NapiDistributeOperationExecuteCallback(napi_env env, void *data) } sptr operationInfo = new (std::nothrow) NotificationOperationInfo(); + if (operationInfo == nullptr) { + ANS_LOGE("create operationInfo failed"); + return; + } operationInfo->SetHashCode(asyncCallbackInfo->hashCode); if (asyncCallbackInfo->operationInfo.withOperationInfo) { operationInfo->SetOperationType(OperationType::DISTRIBUTE_OPERATION_REPLY); -- Gitee