diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn index 19e02b6a45bf0d3f5461781bd8d44a4943900fd1..0c70ef0877467bafe184f7329e0fd48b8970cd50 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn @@ -23,6 +23,9 @@ group("fuzztest") { "dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer:fuzztest", "dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer:fuzztest", "dscreen_sink_proxy/sinkproxydscreennotify_fuzzer:fuzztest", + "dscreen_source_callback/callbackonnotifyregresult_fuzzer:fuzztest", + "dscreen_source_callback/callbackonnotifyunregresult_fuzzer:fuzztest", + "dscreen_source_callback/callbackonremoterequest_fuzzer:fuzztest", "dscreen_source_handler/handlerconfigdistributedhardware_fuzzer:fuzztest", "dscreen_source_handler/handlerinitsource_fuzzer:fuzztest", "dscreen_source_handler/handleronremotesourcesvrdied_fuzzer:fuzztest", diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..52db1b2cd5effdccfdb293bd3434b5eeae882e8f --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallBackOnNotifyRegResultFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + "${fwk_services_path}/distributedhardwarefwkservice/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonnotifyregresult_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallBackOnNotifyRegResultFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallBackOnNotifyRegResultFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..540a86c10e192e901b2770572b29fa882fc240ca --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "callbackonnotifyregresult_fuzzer.h" + +#include +#include +#include + +#include "component_enable.h" +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +void OnNotifyRegResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + std::shared_ptr callback = std::make_shared(); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + dScreenSourceCallback->PushRegRegisterCallback(reqId, callback); + dScreenSourceCallback->OnNotifyRegResult(devId, dhId, reqId, status, dataStr); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnNotifyRegResultFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2d909d8c4477332d9bbbabe3deb5aeaa99f30b99 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CALLBACKONNOTIFYREGRESULT_FUZZER_H +#define CALLBACKONNOTIFYREGRESULT_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonnotifyregresult_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1990660529cc278515f7cdb9cd66952318ad41c1 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallBackOnNotifyUnregResultFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + "${fwk_services_path}/distributedhardwarefwkservice/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonnotifyunregresult_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallBackOnNotifyUnregResultFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallBackOnNotifyUnregResultFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f1bea6f20b2cb418972b59ac19ecd543c214ed3 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "callbackonnotifyunregresult_fuzzer.h" + +#include +#include +#include + +#include "component_disable.h" +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +void OnNotifyUnregResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + std::shared_ptr uncallback = std::make_shared(); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + + dScreenSourceCallback->PushUnregisterCallback(reqId, uncallback); + dScreenSourceCallback->OnNotifyUnregResult(devId, dhId, reqId, status, dataStr); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnNotifyUnregResultFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d4d60c9af279504b87ebe285a40ae2f6be964e0c --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CALLBACKONNOTIFYUNREGRESULT_FUZZER_H +#define CALLBACKONNOTIFYUNREGRESULT_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonnotifyunregresult_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7d0dde8c0129e4f3645ebc5e66c443ecb018ef40 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn @@ -0,0 +1,72 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallbackOnRemoteRequestFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonremoterequest_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallbackOnRemoteRequestFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallbackOnRemoteRequestFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7d84b784f2a9ad0771bb6845817f926bfce28426 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "callbackonremoterequest_fuzzer.h" + +#include +#include +#include + +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_callback_stub.h" +#include "dscreen_source_proxy.h" +#include "iremote_object.h" +#include "message_option.h" +#include "message_parcel.h" + +namespace OHOS { +namespace DistributedHardware { +void CallbackOnRemoteRequestFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + MessageParcel pdata; + MessageParcel reply; + MessageOption option; + uint32_t code = *(reinterpret_cast(data)) % 2; + int32_t status = *(reinterpret_cast(data)); + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + std::string dataStr(reinterpret_cast(data), size); + pdata.WriteInt32(status); + pdata.WriteString(devId); + pdata.WriteString(dhId); + pdata.WriteString(reqId); + pdata.WriteString(dataStr); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + dScreenSourceCallback->OnRemoteRequest(code, pdata, reply, option); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::CallbackOnRemoteRequestFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..05ff48f27fd53efed96bdb0e57e66972dd711d03 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CALLBACKONREMOTEREQUEST_FUZZER_H +#define CALLBACKONREMOTEREQUEST_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonremoterequest_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + +