diff --git a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp index 10c38f2df62e8bab0843fb7d4ad35f3f701dd08e..8c860a8359cedc0b085a43dae427a06948a5be5e 100644 --- a/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/checkpersistpolicystub_fuzzer/checkpersistpolicystub_fuzzer.cpp @@ -47,13 +47,17 @@ namespace OHOS { return false; } + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); if (!datas.WriteUint32(tokenId)) { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + if (!datas.WriteUint32(policyRawData.size)) { + return false; + } + + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { return false; } diff --git a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp index fe1351bade0ef2f1984da2c466fe7a245baadf24..530022028dd0bc167b3e1c07bd71ac0124168398 100644 --- a/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/checkpolicystub_fuzzer/checkpolicystub_fuzzer.cpp @@ -46,13 +46,17 @@ namespace OHOS { return false; } + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); if (!datas.WriteUint32(tokenId)) { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + if (!datas.WriteUint32(policyRawData.size)) { + return false; + } + + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { return false; } diff --git a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp index 88e64ebe68128a169e40f302f08b2a6b8bf0a3cd..16bb23a4b772b0011e70f3f0b696e63bbd44ab61 100644 --- a/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/startaccessingpolicystub_fuzzer/startaccessingpolicystub_fuzzer.cpp @@ -25,6 +25,8 @@ #define private public #include "sandbox_manager_service.h" #undef private +#include "accesstoken_kit.h" +#include "token_setproc.h" using namespace OHOS::AccessControl::SandboxManager; @@ -39,18 +41,36 @@ namespace OHOS { std::vector result; PolicyInfoRandomGenerator gen(data, size); gen.GeneratePolicyInfoVec(policyVec); + uint32_t tokenId = GetSelfTokenID(); MessageParcel datas; if (!datas.WriteInterfaceToken(ISandboxManager::GetDescriptor())) { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); + if (!datas.WriteUint32(policyRawData.size)) { + return false; + } + + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { + return false; + } + + uint32_t useCallerToken = gen.GetData(); + if (!datas.WriteUint32(useCallerToken)) { + return false; + } + + if (!datas.WriteUint32(tokenId)) { + return false; + } + + uint32_t timestamp = gen.GetData(); + if (!datas.WriteUint64(timestamp)) { return false; } - uint32_t code = static_cast(ISandboxManagerIpcCode::COMMAND_START_ACCESSING_POLICY); MessageParcel reply; @@ -73,4 +93,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::StartAccessingPolicyStubFuzzTest(data, size); return 0; -} \ No newline at end of file +} diff --git a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp index 6a28961da03a353913ba8cf321cd9c31f4ef30c0..404f5b2b5ebb00055cce7baf41408bc24d7de0ff 100644 --- a/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/stopaccessingpolicystub_fuzzer/stopaccessingpolicystub_fuzzer.cpp @@ -45,9 +45,13 @@ namespace OHOS { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); + if (!datas.WriteUint32(policyRawData.size)) { + return false; + } + + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { return false; } diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp index 03a724764da8561e89acd0d4b3723b7dee9f7386..f010edcd57f92f0b43cef9fcff65a24fbaa60256 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicystub_fuzzer/unpersistpolicystub_fuzzer.cpp @@ -45,9 +45,13 @@ namespace OHOS { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); + if (!datas.WriteUint32(policyRawData.size)) { + return false; + } + + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { return false; } @@ -73,4 +77,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::UnpersistPolicyStubFuzzTest(data, size); return 0; -} \ No newline at end of file +} diff --git a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp index 9fcc43d1eb94d1ea52538db497616c1e25e14eda..cb6d195b0dc3c6d0f21728ebbbb3cf08a4860269 100644 --- a/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp +++ b/test/fuzztest/services/sandbox_manager/unpersistpolicytokenstub_fuzzer/unpersistpolicytokenstub_fuzzer.cpp @@ -41,6 +41,8 @@ namespace OHOS { uint32_t tokenId = gen.GetData(); gen.GeneratePolicyInfoVec(policyVec); + PolicyVecRawData policyRawData; + policyRawData.Marshalling(policyVec); MessageParcel datas; if (!datas.WriteInterfaceToken(ISandboxManager::GetDescriptor())) { return false; @@ -50,12 +52,13 @@ namespace OHOS { return false; } - PolicyInfoVectorParcel policyInfoParcel; - policyInfoParcel.policyVector = policyVec; - if (!datas.WriteParcelable(&policyInfoParcel)) { + if (!datas.WriteUint32(policyRawData.size)) { return false; } + if (!datas.WriteRawData(policyRawData.data, policyRawData.size)) { + return false; + } uint32_t code = static_cast(ISandboxManagerIpcCode::COMMAND_UN_PERSIST_POLICY_BY_TOKEN_ID); MessageParcel reply;