From f198aa82234fffbcb94c9f3e36c12d86c3c93847 Mon Sep 17 00:00:00 2001 From: wangjingchang Date: Wed, 30 Jul 2025 20:43:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ProxyRunningLocksFuzzTest=E7=94=A8?= =?UTF-8?q?=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: wangjingchang --- frameworks/native/running_lock_info.cpp | 4 ++++ .../src/interface_test/running_lock_test.cpp | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/frameworks/native/running_lock_info.cpp b/frameworks/native/running_lock_info.cpp index b55dbd04..c6127c2b 100644 --- a/frameworks/native/running_lock_info.cpp +++ b/frameworks/native/running_lock_info.cpp @@ -88,6 +88,10 @@ VectorPair* VectorPair::Unmarshalling(Parcel& parcel) int32_t size {0}; RETURN_IF_READ_PARCEL_FAILED_WITH_RET(parcel, Int32, size, nullptr); + if (size <= 0) { + POWER_HILOGW(COMP_FWK, "size is negative, size=%{public}d", size); + return nullptr; + } if (size > MAX_PROXY_RUNNINGLOCK_NUM) { POWER_HILOGW(COMP_FWK, "size exceed limit, size=%{public}d", size); return nullptr; diff --git a/test/unittest/src/interface_test/running_lock_test.cpp b/test/unittest/src/interface_test/running_lock_test.cpp index fec4b0ed..e00a37b2 100644 --- a/test/unittest/src/interface_test/running_lock_test.cpp +++ b/test/unittest/src/interface_test/running_lock_test.cpp @@ -596,4 +596,28 @@ HWTEST_F(RunningLockTest, RunningLockTest021, TestSize.Level1) EXPECT_EQ(result, ERR_INVALID_DATA); POWER_HILOGI(LABEL_TEST, "RunningLockTest021 function end!"); } + +HWTEST_F(RunningLockTest, RunningLockTest022, TestSize.Level1) +{ + POWER_HILOGI(LABEL_TEST, "RunningLockTest022 function start!"); + EXPECT_NE(stub_, nullptr); + + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + data.WriteInterfaceToken(PowerMgrProxy::GetDescriptor()); + data.WriteInt32(1); + + VectorPair vectorPairInfos; + std::vector> processInfos; + vectorPairInfos.SetProcessInfos(processInfos); + + EXPECT_TRUE(data.WriteParcelable(&vectorPairInfos)); + + int32_t result = stub_->OnRemoteRequest( + static_cast(IPowerMgrIpcCode::COMMAND_PROXY_RUNNING_LOCKS_IPC), data, reply, option); + + EXPECT_EQ(result, ERR_INVALID_DATA); + POWER_HILOGI(LABEL_TEST, "RunningLockTest022 function end!"); +} } // namespace \ No newline at end of file -- Gitee