From 07a72c6bf6270645a0194ed414d175370d159972 Mon Sep 17 00:00:00 2001 From: wufarong1 Date: Fri, 23 Aug 2024 11:48:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fuzzer=E7=94=A8=E4=BE=8B=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wufarong1 Change-Id: Ib23429800bce06f0b3e3de1937b0054875598e91 --- frameworks/ans/src/notification_request.cpp | 1 + .../ansmanagerstub_fuzzer.cpp | 4 ++++ .../anssubscriberstub_fuzzer.cpp | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index 90ce75934..2ba8358e5 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -2253,6 +2253,7 @@ bool NotificationRequest::ConvertJsonToNotificationDistributedOptions( } target->distributedOptions_ = *pOpt; + delete pOpt; } } diff --git a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp index 71e6f7cda..8ef7cb4d5 100644 --- a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp +++ b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp @@ -44,6 +44,10 @@ namespace OHOS { MessageParcel datas; MessageParcel reply; MessageOption flags; + // test HandleIsNeedSilentInDoNotDisturbMode function + ansManagerStub.HandleIsNeedSilentInDoNotDisturbMode(datas, reply); + // test HandleRegisterSwingCallback function + ansManagerStub.HandleRegisterSwingCallback(datas, reply); ansManagerStub.OnRemoteRequest(0, datas, reply, flags); ansManagerStub.OnRemoteRequest((int) Notification::NotificationInterfaceCode::PUBLISH_NOTIFICATION, datas, reply, flags); diff --git a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp index a9aac1a98..d8ebb0476 100644 --- a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp +++ b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "ans_subscriber_local_live_view_stub.h" #define private public #define protected public #include "ans_subscriber_stub.h" @@ -26,6 +27,7 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { Notification::AnsSubscriberStub ansSubscriberStub; + Notification::AnsSubscriberLocalLiveViewStub ansSubscriberLocalLiveViewStub; uint32_t code = GetU32Data(data); MessageParcel datas; MessageParcel reply; @@ -64,6 +66,20 @@ namespace OHOS { ansSubscriberStub.OnDoNotDisturbDateChange(date); // test OnEnabledNotificationChanged function sptr callbackData = new Notification::EnabledNotificationCallbackData(); + // test HandleOnBadgeEnabledChanged function + ansSubscriberStub.HandleOnBadgeEnabledChanged(datas, reply); + // test HandleOnResponse function + ansSubscriberLocalLiveViewStub.HandleOnResponse(datas, reply); + // test HandleOnConsumedListMap function + ansSubscriberStub.HandleOnConsumedListMap(datas, reply); + // test HandleOnDisconnected function + ansSubscriberLocalLiveViewStub.HandleOnDisconnected(datas, reply); + // test HandleOnBadgeChanged function + ansSubscriberStub.HandleOnBadgeChanged(datas, reply); + // test HandleOnCanceledListMap function + ansSubscriberStub.HandleOnCanceledListMap(datas, reply); + // test HandleOnConnected function + ansSubscriberLocalLiveViewStub.HandleOnConnected(datas, reply); return true; } } -- Gitee From b41c2d8f3b36a1f70d6343441ece2755fa703db7 Mon Sep 17 00:00:00 2001 From: wufarong1 Date: Tue, 27 Aug 2024 11:19:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ANS=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: wufarong1 Change-Id: I59caa0e454aa3f16f98cebdd2cb17015178e732a --- frameworks/ans/src/notification_local_live_view_button.cpp | 1 + frameworks/ans/src/notification_request.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/frameworks/ans/src/notification_local_live_view_button.cpp b/frameworks/ans/src/notification_local_live_view_button.cpp index 81d163d51..df5bb1d07 100644 --- a/frameworks/ans/src/notification_local_live_view_button.cpp +++ b/frameworks/ans/src/notification_local_live_view_button.cpp @@ -172,6 +172,7 @@ NotificationLocalLiveViewButton *NotificationLocalLiveViewButton::FromJson(const auto pIcon = AnsImageUtil::UnPackImage(iconObj.get()); if (pIcon == nullptr) { ANS_LOGE("Failed to parse button icon"); + delete button; return nullptr; } button->buttonIcons_.emplace_back(pIcon); diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index 90ce75934..045d3102f 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -2256,6 +2256,7 @@ bool NotificationRequest::ConvertJsonToNotificationDistributedOptions( } } + delete pOpt; return true; } -- Gitee