mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-23 06:59:59 +00:00
update test/fuzztest/storagetotalstatusservice_fuzzer/storagetotalstatusservice_fuzzer.cpp.
Signed-off-by: lixiyuan <lixiyuan7@huawei.com>
This commit is contained in:
parent
1df4c33ed2
commit
c139d4312f
@ -29,13 +29,14 @@ T TypeCast(const uint8_t *data, int *pos)
|
||||
|
||||
bool StorageTotalStatusServiceFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
if ((data == nullptr) || (size < sizeof(uint64_t) * 3)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<StorageTotalStatusService> service = DelayedSingleton<StorageTotalStatusService>::GetInstance();
|
||||
int64_t totalSize;
|
||||
int64_t systemSize;
|
||||
int64_t freeSize;
|
||||
int64_t totalSize = TypeCast<int64_t>(data, nullptr);
|
||||
int64_t systemSize = TypeCast<int64_t>(data + sizeof(int64_t), nullptr);
|
||||
int64_t freeSize = TypeCast<int64_t>(data + sizeof(int64_t) * 2, nullptr);
|
||||
int32_t result = service->GetTotalSize(totalSize);
|
||||
if (result != E_OK) {
|
||||
LOGI("Storage total status service fuzz test of interface StorageTotalStatusService::GetTotalSize failed!");
|
||||
|
Loading…
Reference in New Issue
Block a user