mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-22 22:09:58 +00:00
修改fuzz告警
Signed-off-by: 师皓杰 <shihaojie10@huawei.com>
This commit is contained in:
parent
e61b21364e
commit
82cbe46ddb
@ -402,17 +402,23 @@ void ReleaseRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size)
|
|||||||
DistributedSchedService::GetInstance().ProcessDeviceOffline(deviceId);
|
DistributedSchedService::GetInstance().ProcessDeviceOffline(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetDistributedComponentListInnerFuzzTest(const uint8_t* data, size_t size)
|
int32_t GetDistributedComponentListInnerFuzzTest(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||||
return;
|
return INVALID_PARAMETERS_ERR;
|
||||||
}
|
}
|
||||||
FuzzUtil::MockPermission();
|
FuzzUtil::MockPermission();
|
||||||
MessageParcel dataParcel;
|
MessageParcel dataParcel;
|
||||||
MessageParcel reply;
|
MessageParcel reply;
|
||||||
MessageOption option;
|
std::vector<std::string> distributedComponents;
|
||||||
|
int32_t int32Data = *(reinterpret_cast<const int32_t*>(data));
|
||||||
|
std::string str(reinterpret_cast<const char*>(data), size);
|
||||||
|
distributedComponents.push_back(str);
|
||||||
|
PARCEL_WRITE_HELPER(reply, Int32, int32Data);
|
||||||
|
PARCEL_WRITE_HELPER(reply, StringVector, distributedComponents);
|
||||||
|
|
||||||
DistributedSchedService::GetInstance().GetDistributedComponentListInner(dataParcel, reply);
|
DistributedSchedService::GetInstance().GetDistributedComponentListInner(dataParcel, reply);
|
||||||
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartRemoteFreeInstallInnerFuzzTest(const uint8_t* data, size_t size)
|
void StartRemoteFreeInstallInnerFuzzTest(const uint8_t* data, size_t size)
|
||||||
|
@ -44,30 +44,38 @@ uint32_t GetU32Data(const char* ptr)
|
|||||||
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
|
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_001(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_001(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
unsigned int flags = static_cast<unsigned int>(GetU32Data(data));
|
unsigned int flags = static_cast<unsigned int>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
want->SetFlags(flags);
|
want->SetFlags(flags);
|
||||||
want->RemoveFlags(flags);
|
want->RemoveFlags(flags);
|
||||||
want->AddFlags(flags);
|
want->AddFlags(flags);
|
||||||
std::string entity(data, size);
|
std::string entity(reinterpret_cast<const char*>(data), size);
|
||||||
want->AddEntity(entity);
|
want->AddEntity(entity);
|
||||||
want->HasEntity(entity);
|
want->HasEntity(entity);
|
||||||
want->RemoveEntity(entity);
|
want->RemoveEntity(entity);
|
||||||
std::string bundleName(data, size);
|
std::string bundleName(reinterpret_cast<const char*>(data), size);
|
||||||
want->SetBundle(bundleName);
|
want->SetBundle(bundleName);
|
||||||
std::string deviceId(data, size);
|
std::string deviceId(reinterpret_cast<const char*>(data), size);
|
||||||
want->SetDeviceId(deviceId);
|
want->SetDeviceId(deviceId);
|
||||||
want->SetElementName(bundleName, entity);
|
want->SetElementName(bundleName, entity);
|
||||||
want->SetElementName(deviceId, bundleName, entity);
|
want->SetElementName(deviceId, bundleName, entity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
std::string type(data, size);
|
std::string type(reinterpret_cast<const char*>(data), size);
|
||||||
want->SetType(type);
|
want->SetType(type);
|
||||||
Uri uri(type);
|
Uri uri(type);
|
||||||
want->SetUri(uri);
|
want->SetUri(uri);
|
||||||
@ -78,28 +86,36 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_002(const char* data, size_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_003(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_003(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
want->CountEntities();
|
want->CountEntities();
|
||||||
want->GetScheme();
|
want->GetScheme();
|
||||||
DistributedOperation operation;
|
DistributedOperation operation;
|
||||||
want->SetOperation(operation);
|
want->SetOperation(operation);
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
want->HasParameter(key);
|
want->HasParameter(key);
|
||||||
std::string content(data, size);
|
std::string content(reinterpret_cast<const char*>(data), size);
|
||||||
std::string prop(data, size);
|
std::string prop(reinterpret_cast<const char*>(data), size);
|
||||||
std::string value(data, size);
|
std::string value(reinterpret_cast<const char*>(data), size);
|
||||||
std::string str(data, size);
|
std::string str(reinterpret_cast<const char*>(data), size);
|
||||||
nlohmann::json wantJson;
|
nlohmann::json wantJson;
|
||||||
want->ReadFromJson(wantJson);
|
want->ReadFromJson(wantJson);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
sptr<IRemoteObject> remoteObject;
|
sptr<IRemoteObject> remoteObject;
|
||||||
want->SetParam(key, remoteObject);
|
want->SetParam(key, remoteObject);
|
||||||
std::vector<bool> boolValue;
|
std::vector<bool> boolValue;
|
||||||
@ -118,10 +134,14 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_004(const char* data, size_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_005(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_005(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
std::vector<zchar> charVector;
|
std::vector<zchar> charVector;
|
||||||
want->SetParam(key, charVector);
|
want->SetParam(key, charVector);
|
||||||
want->GetCharArrayParam(key);
|
want->GetCharArrayParam(key);
|
||||||
@ -143,10 +163,14 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_005(const char* data, size_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
std::shared_ptr<DistributedWant> want = std::make_shared<DistributedWant>();
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
std::vector<float> floatVector;
|
std::vector<float> floatVector;
|
||||||
want->SetParam(key, floatVector);
|
want->SetParam(key, floatVector);
|
||||||
want->GetFloatArrayParam(key);
|
want->GetFloatArrayParam(key);
|
||||||
@ -162,7 +186,7 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const char* data, size_
|
|||||||
std::vector<short> shortVector;
|
std::vector<short> shortVector;
|
||||||
want->SetParam(key, shortVector);
|
want->SetParam(key, shortVector);
|
||||||
want->GetShortArrayParam(key);
|
want->GetShortArrayParam(key);
|
||||||
std::string stringValue(data, size);
|
std::string stringValue(reinterpret_cast<const char*>(data), size);
|
||||||
want->SetParam(key, stringValue);
|
want->SetParam(key, stringValue);
|
||||||
want->GetStringParam(key);
|
want->GetStringParam(key);
|
||||||
std::vector<std::string> stringVector;
|
std::vector<std::string> stringVector;
|
||||||
@ -185,38 +209,11 @@ bool DoSomethingInterestingWithMyAPI_DistributedWant_006(const char* data, size_
|
|||||||
/* Fuzzer entry point */
|
/* Fuzzer entry point */
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
/* Run your code on data */
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_001(data, size);
|
||||||
if (data == nullptr) {
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_002(data, size);
|
||||||
std::cout << "invalid data" << std::endl;
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_003(data, size);
|
||||||
return 0;
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_004(data, size);
|
||||||
}
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_005(data, size);
|
||||||
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_006(data, size);
|
||||||
/* Validate the length of size */
|
|
||||||
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* ch = reinterpret_cast<char *>(malloc(size + 1));
|
|
||||||
if (ch == nullptr) {
|
|
||||||
std::cout << "malloc failed." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)memset_s(ch, size + 1, 0x00, size + 1);
|
|
||||||
if (memcpy_s(ch, size + 1, data, size) != EOK) {
|
|
||||||
std::cout << "copy failed." << std::endl;
|
|
||||||
free(ch);
|
|
||||||
ch = nullptr;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_001(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_002(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_003(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_004(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_005(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWant_006(ch, size);
|
|
||||||
free(ch);
|
|
||||||
ch = nullptr;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,14 @@ uint32_t GetU32Data(const char* ptr)
|
|||||||
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
|
return (ptr[POS_0] << OFFSET_24) | (ptr[POS_1] << OFFSET_16) | (ptr[POS_2] << OFFSET_8) | ptr[POS_3];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_001(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_001(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DistributedWantParams wantOther;
|
DistributedWantParams wantOther;
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
||||||
sptr<AAFwk::IArray> array = new (std::nothrow) AAFwk::Array(0, DistributedSchedule::g_IID_IDistributedWantParams);
|
sptr<AAFwk::IArray> array = new (std::nothrow) AAFwk::Array(0, DistributedSchedule::g_IID_IDistributedWantParams);
|
||||||
wantParams->SetParam(key, array);
|
wantParams->SetParam(key, array);
|
||||||
@ -71,14 +75,15 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_001(const char* data,
|
|||||||
wantParams->HasParam(key);
|
wantParams->HasParam(key);
|
||||||
wantParams->IsEmpty();
|
wantParams->IsEmpty();
|
||||||
wantParams->GetParams();
|
wantParams->GetParams();
|
||||||
|
|
||||||
Parcel parcel;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DistributedWantParams wantOther;
|
DistributedWantParams wantOther;
|
||||||
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
||||||
Parcel parcel;
|
Parcel parcel;
|
||||||
@ -92,10 +97,10 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const char* data,
|
|||||||
wantParams->WriteArrayToParcelLong(parcel, ao);
|
wantParams->WriteArrayToParcelLong(parcel, ao);
|
||||||
wantParams->WriteArrayToParcelFloat(parcel, ao);
|
wantParams->WriteArrayToParcelFloat(parcel, ao);
|
||||||
wantParams->WriteArrayToParcelDouble(parcel, ao);
|
wantParams->WriteArrayToParcelDouble(parcel, ao);
|
||||||
long longValue = static_cast<long>(GetU32Data(data));
|
long longValue = static_cast<long>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> longIt = Long::Box(longValue);
|
sptr<IInterface> longIt = Long::Box(longValue);
|
||||||
wantParams->WriteToParcelLong(parcel, longIt);
|
wantParams->WriteToParcelLong(parcel, longIt);
|
||||||
float floatValue = static_cast<float>(GetU32Data(data));
|
float floatValue = static_cast<float>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> floatIt = Float::Box(floatValue);
|
sptr<IInterface> floatIt = Float::Box(floatValue);
|
||||||
wantParams->WriteToParcelFloat(parcel, floatIt);
|
wantParams->WriteToParcelFloat(parcel, floatIt);
|
||||||
|
|
||||||
@ -109,44 +114,48 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_002(const char* data,
|
|||||||
wantParams->ReadFromParcelArrayLong(parcel, array);
|
wantParams->ReadFromParcelArrayLong(parcel, array);
|
||||||
wantParams->ReadFromParcelArrayFloat(parcel, array);
|
wantParams->ReadFromParcelArrayFloat(parcel, array);
|
||||||
wantParams->ReadFromParcelArrayDouble(parcel, array);
|
wantParams->ReadFromParcelArrayDouble(parcel, array);
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
wantParams->ReadFromParcelLong(parcel, key);
|
wantParams->ReadFromParcelLong(parcel, key);
|
||||||
wantParams->ReadFromParcelFloat(parcel, key);
|
wantParams->ReadFromParcelFloat(parcel, key);
|
||||||
|
|
||||||
wantParams->ReadArrayToParcel(parcel, GetU32Data(data) % OFFSET_16, array);
|
wantParams->ReadArrayToParcel(parcel, GetU32Data(reinterpret_cast<const char*>(data)) % OFFSET_16, array);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_003(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_003(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DistributedWantParams wantOther;
|
DistributedWantParams wantOther;
|
||||||
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
||||||
Parcel parcel;
|
Parcel parcel;
|
||||||
std::string key(data, size);
|
std::string key(reinterpret_cast<const char*>(data), size);
|
||||||
int8_t byteValue = static_cast<int8_t>(GetU32Data(data));
|
int8_t byteValue = static_cast<int8_t>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> byteIt = Byte::Box(byteValue);
|
sptr<IInterface> byteIt = Byte::Box(byteValue);
|
||||||
wantParams->WriteToParcelByte(parcel, byteIt);
|
wantParams->WriteToParcelByte(parcel, byteIt);
|
||||||
sptr<IInterface> stringIt = String::Box(key);
|
sptr<IInterface> stringIt = String::Box(key);
|
||||||
wantParams->WriteToParcelString(parcel, stringIt);
|
wantParams->WriteToParcelString(parcel, stringIt);
|
||||||
bool boolValue = static_cast<bool>(GetU32Data(data) > FOO_MAX_LEN);
|
bool boolValue = static_cast<bool>(GetU32Data(reinterpret_cast<const char*>(data)) > FOO_MAX_LEN);
|
||||||
sptr<IInterface> boolIt = Boolean::Box(boolValue);
|
sptr<IInterface> boolIt = Boolean::Box(boolValue);
|
||||||
wantParams->WriteToParcelBool(parcel, boolIt);
|
wantParams->WriteToParcelBool(parcel, boolIt);
|
||||||
char charValue = *data;
|
char charValue = *data;
|
||||||
sptr<IInterface> charIt = Char::Box(charValue);
|
sptr<IInterface> charIt = Char::Box(charValue);
|
||||||
wantParams->WriteToParcelChar(parcel, charIt);
|
wantParams->WriteToParcelChar(parcel, charIt);
|
||||||
short shortValue = static_cast<short>(GetU32Data(data));
|
short shortValue = static_cast<short>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> shortIt = Short::Box(shortValue);
|
sptr<IInterface> shortIt = Short::Box(shortValue);
|
||||||
wantParams->WriteToParcelShort(parcel, shortIt);
|
wantParams->WriteToParcelShort(parcel, shortIt);
|
||||||
double doubleValue = static_cast<double>(GetU32Data(data));
|
double doubleValue = static_cast<double>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> doubleIt = Double::Box(doubleValue);
|
sptr<IInterface> doubleIt = Double::Box(doubleValue);
|
||||||
wantParams->WriteToParcelDouble(parcel, doubleIt);
|
wantParams->WriteToParcelDouble(parcel, doubleIt);
|
||||||
int32_t intValue = static_cast<int32_t>(GetU32Data(data));
|
int32_t intValue = static_cast<int32_t>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
sptr<IInterface> intIt = Integer::Box(intValue);
|
sptr<IInterface> intIt = Integer::Box(intValue);
|
||||||
wantParams->WriteToParcelInt(parcel, intIt);
|
wantParams->WriteToParcelInt(parcel, intIt);
|
||||||
wantParams->WriteToParcelFD(parcel, wantOther);
|
wantParams->WriteToParcelFD(parcel, wantOther);
|
||||||
wantParams->WriteToParcelRemoteObject(parcel, wantOther);
|
wantParams->WriteToParcelRemoteObject(parcel, wantOther);
|
||||||
|
|
||||||
int type = static_cast<int>(GetU32Data(data));
|
int type = static_cast<int>(GetU32Data(reinterpret_cast<const char*>(data)));
|
||||||
wantParams->ReadFromParcelInt8(parcel, key);
|
wantParams->ReadFromParcelInt8(parcel, key);
|
||||||
wantParams->ReadFromParcelString(parcel, key);
|
wantParams->ReadFromParcelString(parcel, key);
|
||||||
wantParams->ReadFromParcelBool(parcel, key);
|
wantParams->ReadFromParcelBool(parcel, key);
|
||||||
@ -169,12 +178,16 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_003(const char* data,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_004(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI_DistributedWantParams_004(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
|
if (data == nullptr ||size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DistributedWantParams wantOther;
|
DistributedWantParams wantOther;
|
||||||
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
std::shared_ptr<DistributedWantParams> wantParams = std::make_shared<DistributedWantParams>(wantOther);
|
||||||
|
|
||||||
std::string value(data, size);
|
std::string value(reinterpret_cast<const char*>(data), size);
|
||||||
sptr<IInterface> stringObj =
|
sptr<IInterface> stringObj =
|
||||||
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
|
DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
|
||||||
wantParams->CompareInterface(stringObj, stringObj, DistributedWantParams::VALUE_TYPE_STRING);
|
wantParams->CompareInterface(stringObj, stringObj, DistributedWantParams::VALUE_TYPE_STRING);
|
||||||
@ -193,36 +206,9 @@ bool DoSomethingInterestingWithMyAPI_DistributedWantParams_004(const char* data,
|
|||||||
/* Fuzzer entry point */
|
/* Fuzzer entry point */
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
/* Run your code on data */
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_001(data, size);
|
||||||
if (data == nullptr) {
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_002(data, size);
|
||||||
std::cout << "invalid data" << std::endl;
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_003(data, size);
|
||||||
return 0;
|
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_004(data, size);
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate the length of size */
|
|
||||||
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* ch = (char *)malloc(size + 1);
|
|
||||||
if (ch == nullptr) {
|
|
||||||
std::cout << "malloc failed." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)memset_s(ch, size + 1, 0x00, size + 1);
|
|
||||||
if (memcpy_s(ch, size + 1, data, size) != EOK) {
|
|
||||||
std::cout << "copy failed." << std::endl;
|
|
||||||
free(ch);
|
|
||||||
ch = nullptr;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_001(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_002(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_003(ch, size);
|
|
||||||
OHOS::DoSomethingInterestingWithMyAPI_DistributedWantParams_004(ch, size);
|
|
||||||
free(ch);
|
|
||||||
ch = nullptr;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user