diff --git a/test/fuzztest/backupsa_fuzzer/backupsa_fuzzer.cpp b/test/fuzztest/backupsa_fuzzer/backupsa_fuzzer.cpp index 8bd10a0d6ab1c2d8d13f96c9421ba6070aff75b7..adbeaf1764a60ceb9fdc8f9f6240ae3a5af8ef04 100644 --- a/test/fuzztest/backupsa_fuzzer/backupsa_fuzzer.cpp +++ b/test/fuzztest/backupsa_fuzzer/backupsa_fuzzer.cpp @@ -15,14 +15,25 @@ #include "backupsa_fuzzer.h" +#include +#include +#include + +#include #include "message_parcel.h" +#include "service_stub.h" #include "service.h" -#include "service_client.h" +#include "securec.h" +#include "system_ability.h" + +#include "filemgmt_libhilog.h" -namespace OHOS { using namespace OHOS::FileManagement::Backup; + +namespace OHOS { constexpr size_t U32_AT_SIZE = 4; -constexpr uint8_t MAX_CALL_TRANSACTION = 40; +constexpr uint8_t MAX_CALL_TRANSACTION = 24; +constexpr int32_t SERVICE_ID = 5203; uint32_t GetU32Data(const char* ptr) { @@ -36,7 +47,7 @@ bool BackupSaFuzzTest(const uint8_t *data, size_t size) return true; } - Service* service = static_cast(ServiceClient::GetInstance()->AsObject().GetRefPtr()); + sptr service = sptr(new Service(SERVICE_ID)); uint32_t code = GetU32Data(reinterpret_cast(data)); if (code == 0) { return true; diff --git a/test/fuzztest/backupservicestub_fuzzer/backupservicestub_fuzzer.cpp b/test/fuzztest/backupservicestub_fuzzer/backupservicestub_fuzzer.cpp index 94f3c897abbe50cc1f8757bed06c06b66b165a84..6b2c9cd2bd2c941ecd1b99aed4ba28be434fe3c2 100644 --- a/test/fuzztest/backupservicestub_fuzzer/backupservicestub_fuzzer.cpp +++ b/test/fuzztest/backupservicestub_fuzzer/backupservicestub_fuzzer.cpp @@ -670,26 +670,6 @@ bool CmdUpdateSendRateFuzzTest(sptr service, const uint8_t *data, size_ } return true; } - -bool CmdGetBackupDataSizeFuzzTest(sptr service, const uint8_t *data, size_t size) -{ - if (data == nullptr || size < sizeof(int32_t) + sizeof(int32_t)) { - return true; - } - - MessageParcel msg; - MessageParcel reply; - MessageOption option; - uint32_t code = static_cast(IServiceIpcCode::COMMAND_GET_BACKUP_DATA_SIZE); - - try { - msg.WriteBuffer(data, size); - service->OnRemoteRequest(code, msg, reply, option); - } catch (OHOS::FileManagement::Backup::BError &err) { - // Only filter BError errors, Other results are not expected. - } - return true; -} } // namespace OHOS /* Fuzzer entry point */ @@ -728,7 +708,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) CmdGetBackupInfoFuzzTest(service, data, size); CmdUpdateTimerFuzzTest(service, data, size); CmdUpdateSendRateFuzzTest(service, data, size); - CmdGetBackupDataSizeFuzzTest(service, data, size); } catch (OHOS::FileManagement::Backup::BError &err) { // Only filter BError errors, Other results are not expected. }