diff --git a/test/fuzztest/stubhandlepointlocation_fuzzer/BUILD.gn b/test/fuzztest/stubhandlepointlocation_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..890e9a951870668591b8bcc4d102ae837c928c7f --- /dev/null +++ b/test/fuzztest/stubhandlepointlocation_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandlePointLocationFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlepointlocation_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlepointlocation_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandlePointLocationFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlepointlocation_fuzzer/corpus/init b/test/fuzztest/stubhandlepointlocation_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlepointlocation_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlepointlocation_fuzzer/project.xml b/test/fuzztest/stubhandlepointlocation_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlepointlocation_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.cpp b/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ed10acf07b61a51d6d4454f266957fb071af0c63 --- /dev/null +++ b/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlepointlocation_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandlePointLocationFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t x = provider.ConsumeIntegral(); + int32_t y = provider.ConsumeIntegral(); + int32_t displayId = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetPointerLocation(x, y, displayId); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandlePointLocationFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.h b/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5480e12fb495429805e52527aee352cd5282f5cf --- /dev/null +++ b/test/fuzztest/stubhandlepointlocation_fuzzer/stubhandlepointlocation_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlepointlocation_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleremoveinput_fuzzer/BUILD.gn b/test/fuzztest/stubhandleremoveinput_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..08a4975f7f0becc4c4a3e60740e4c9e2e0b7f0a3 --- /dev/null +++ b/test/fuzztest/stubhandleremoveinput_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleRemoveInputFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleremoveinput_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandleremoveinput_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleRemoveInputFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleremoveinput_fuzzer/corpus/init b/test/fuzztest/stubhandleremoveinput_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandleremoveinput_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandleremoveinput_fuzzer/project.xml b/test/fuzztest/stubhandleremoveinput_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandleremoveinput_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.cpp b/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6b8c08a750b671eccc6d7ace1a315298ab1b9a52 --- /dev/null +++ b/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandleremoveinput_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleRemoveInputFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t handlerType = provider.ConsumeIntegral(); + uint32_t eventType = provider.ConsumeIntegral(); + int32_t priority = provider.ConsumeIntegral(); + uint32_t deviceTags = provider.ConsumeIntegral(); + + MMIService::GetInstance()->RemoveInputHandler(handlerType, eventType, priority, deviceTags); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleRemoveInputFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.h b/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c65c4b4a46f7647bb844dd8f62780214e5e88554 --- /dev/null +++ b/test/fuzztest/stubhandleremoveinput_fuzzer/stubhandleremoveinput_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandleremoveinput_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlerotateswitch_fuzzer/BUILD.gn b/test/fuzztest/stubhandlerotateswitch_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..16a990da349162e92855482e7fc45cab6dcac0cd --- /dev/null +++ b/test/fuzztest/stubhandlerotateswitch_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleRotateSwitchFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlerotateswitch_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlerotateswitch_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleRotateSwitchFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlerotateswitch_fuzzer/corpus/init b/test/fuzztest/stubhandlerotateswitch_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlerotateswitch_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlerotateswitch_fuzzer/project.xml b/test/fuzztest/stubhandlerotateswitch_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlerotateswitch_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.cpp b/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5a9ab7142384f4e4d0b10aff4f5f908f5f5da68 --- /dev/null +++ b/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlerotateswitch_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleRotateSwitchFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + bool rotateSwitch = provider.ConsumeBool(); + + MMIService::GetInstance()->SetTouchpadRotateSwitch(rotateSwitch); + MMIService::GetInstance()->ReadTouchpadRotateSwitch(rotateSwitch); + MMIService::GetInstance()->GetTouchpadRotateSwitch(rotateSwitch); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleRotateSwitchFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.h b/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5386a4bf3e94a524fc5494817b80c3462ea19b27 --- /dev/null +++ b/test/fuzztest/stubhandlerotateswitch_fuzzer/stubhandlerotateswitch_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlerotateswitch_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlescrolldirection_fuzzer/BUILD.gn b/test/fuzztest/stubhandlescrolldirection_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1139a2d09950b209ceca3d9d1396e18f601152d1 --- /dev/null +++ b/test/fuzztest/stubhandlescrolldirection_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleScrollDirectionFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlescrolldirection_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlescrolldirection_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleScrollDirectionFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlescrolldirection_fuzzer/corpus/init b/test/fuzztest/stubhandlescrolldirection_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlescrolldirection_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlescrolldirection_fuzzer/project.xml b/test/fuzztest/stubhandlescrolldirection_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlescrolldirection_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.cpp b/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4fbc8b638868216a59b91e6f0cbd978ab086af5e --- /dev/null +++ b/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlescrolldirection_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleScrollDirectionFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + bool switchFlag = provider.ConsumeBool(); + + MMIService::GetInstance()->SetTouchpadScrollDirection(switchFlag); + MMIService::GetInstance()->ReadTouchpadScrollDirection(switchFlag); + MMIService::GetInstance()->GetTouchpadScrollDirection(switchFlag); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleScrollDirectionFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.h b/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9e7b5b3750782ac54583952c59a6327734bc5875 --- /dev/null +++ b/test/fuzztest/stubhandlescrolldirection_fuzzer/stubhandlescrolldirection_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlescrolldirection_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlescrollrows_fuzzer/BUILD.gn b/test/fuzztest/stubhandlescrollrows_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8e9b703f4cf3994552ed16f6ffc2c878ae1eedae --- /dev/null +++ b/test/fuzztest/stubhandlescrollrows_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleScrollRowsFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlescrollrows_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlescrollrows_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleScrollRowsFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlescrollrows_fuzzer/corpus/init b/test/fuzztest/stubhandlescrollrows_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlescrollrows_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlescrollrows_fuzzer/project.xml b/test/fuzztest/stubhandlescrollrows_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlescrollrows_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.cpp b/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d26b180599e8d5201d09a7704659aad043c675e7 --- /dev/null +++ b/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlescrollrows_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleReadMouseFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleScrollRowsFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t rows = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetMouseScrollRows(rows); + MMIService::GetInstance()->ReadMouseScrollRows(rows); + MMIService::GetInstance()->GetMouseScrollRows(rows); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleScrollRowsFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.h b/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..50b2dcad4b9f89dfddb22aa8906b6f2d5a903308 --- /dev/null +++ b/test/fuzztest/stubhandlescrollrows_fuzzer/stubhandlescrollrows_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlescrollrows_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlesetbind_fuzzer/BUILD.gn b/test/fuzztest/stubhandlesetbind_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b40663732da4d9cdb26f280f178cfb5ddc668e9c --- /dev/null +++ b/test/fuzztest/stubhandlesetbind_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleSetBindFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlesetbind_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlesetbind_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleSetBindFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlesetbind_fuzzer/corpus/init b/test/fuzztest/stubhandlesetbind_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlesetbind_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlesetbind_fuzzer/project.xml b/test/fuzztest/stubhandlesetbind_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlesetbind_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.cpp b/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..42ab1243983eb8857e2fbb7d6ae1c72824d5e151 --- /dev/null +++ b/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlesetbind_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleSetBindFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t deviceId = provider.ConsumeIntegral(); + int32_t displayId = provider.ConsumeIntegral(); + std::string msg = provider.ConsumeBytesAsString(10); // test value + + MMIService::GetInstance()->SetDisplayBind(deviceId, displayId, msg); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleSetBindFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.h b/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..502359aaa836a141fa3d0c2bd360beb1d0604976 --- /dev/null +++ b/test/fuzztest/stubhandlesetbind_fuzzer/stubhandlesetbind_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlesetbind_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlesetkeyboard_fuzzer/BUILD.gn b/test/fuzztest/stubhandlesetkeyboard_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b2c5555beb8c84c968c0c1016f420ac56af6d7d8 --- /dev/null +++ b/test/fuzztest/stubhandlesetkeyboard_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleSetKeyBoardFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlesetkeyboard_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlesetkeyboard_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleSetKeyBoardFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlesetkeyboard_fuzzer/corpus/init b/test/fuzztest/stubhandlesetkeyboard_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlesetkeyboard_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlesetkeyboard_fuzzer/project.xml b/test/fuzztest/stubhandlesetkeyboard_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlesetkeyboard_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.cpp b/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..05d9a3e2663d384295649cbbf74b0ed1bd9c1de9 --- /dev/null +++ b/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlesetkeyboard_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleSetKeyboardFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t delay = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetKeyboardRepeatDelay(delay); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleSetKeyboardFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.h b/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d1c63ea21c159834ee21e415b1254ec46ed52ec0 --- /dev/null +++ b/test/fuzztest/stubhandlesetkeyboard_fuzzer/stubhandlesetkeyboard_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlesetkeyboard_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlesetmouseicon_fuzzer/BUILD.gn b/test/fuzztest/stubhandlesetmouseicon_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c518fdac91f511f9dabe3884affc5648f5565a1f --- /dev/null +++ b/test/fuzztest/stubhandlesetmouseicon_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# Copyright (c) 2025 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("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("StubHandleSetMouseIconFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlesetmouseicon_fuzzer" + include_dirs = [ + "${mmi_path}/interfaces/util/common/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/filter/include/", + "${mmi_path}/service/nap_process/include/", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/service/delegate_task/include", + "${mmi_path}/service/event_handler/include", + "${mmi_path}/service/event_dispatch/include", + "${mmi_path}/service/interceptor/include", + "${mmi_path}/service/joystick/include", + "${mmi_path}/service/monitor/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/mouse_event_normalize/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/libinput_adapter/include", + "${mmi_path}/service/message_handle/include", + "${mmi_path}/service/touch_event_normalize/include", + "${mmi_path}/util/common/include", + "${mmi_path}/common/anco/comm/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + ] + + configs = [ + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/service/connect_manager:mmi_connect_manager_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + sources = [ "stubhandlesetmouseicon_fuzzer.cpp" ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", + "graphic_2d:librender_service_client", + "hilog:libhilog", + "image_framework:image_native", + "ipc:ipc_single", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libwm", + ] + + if (security_component_enable) { + external_deps += [ "security_component_manager:libsecurity_component_sdk" ] + } + + if (enable_player_framework) { + external_deps += [ "player_framework:media_client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":StubHandleSetMouseIconFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlesetmouseicon_fuzzer/corpus/init b/test/fuzztest/stubhandlesetmouseicon_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /dev/null +++ b/test/fuzztest/stubhandlesetmouseicon_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2025 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/test/fuzztest/stubhandlesetmouseicon_fuzzer/project.xml b/test/fuzztest/stubhandlesetmouseicon_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /dev/null +++ b/test/fuzztest/stubhandlesetmouseicon_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.cpp b/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..507d4e714bbea4a5bb7815de688bf2cda32a29ea --- /dev/null +++ b/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 +#include "stubhandlesetmouseicon_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleSetMouseIconFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleSetMouseIconFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t windowId = provider.ConsumeIntegral(); + CursorPixelMap cursorPixelMap; + + MMIService::GetInstance()->SetMouseIcon(windowId, cursorPixelMap); +} + +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + OHOS::MMI::StubHandleSetMouseIconFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.h b/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..72d9cd30aa64ae84eef20da74f40e90ed573e600 --- /dev/null +++ b/test/fuzztest/stubhandlesetmouseicon_fuzzer/stubhandlesetmouseicon_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H + +#define FUZZ_PROJECT_NAME "stubhandlesetmouseicon_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H