diff --git a/frameworks/native/running_lock_info.cpp b/frameworks/native/running_lock_info.cpp index b55dbd04b582089485b3466aa4a53ea7289cdf2d..c6127c2b8cc42472a90e0aa5cb2ad8f7b9ca655d 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 fec4b0edd31a7f9f92dd9852397e017abef0f306..e00a37b2e650fabb429ffc5474b27ed4df9640c1 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