From 7b0fb61a4a97bb1c179d2f6322c74cfc18a70b2d Mon Sep 17 00:00:00 2001 From: huxianghao Date: Sat, 13 Sep 2025 03:58:14 +0000 Subject: [PATCH] [test]:Modify fuzz stubhandle 3 Signed-off-by: huxianghao --- .../stubhandlemarkprocessed_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../stubhandlemarkprocessed_fuzzer.cpp | 52 +++++++++ .../stubhandlemarkprocessed_fuzzer.h | 21 ++++ .../stubhandlemovemouse_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlemovemouse_fuzzer/corpus/init | 14 +++ .../stubhandlemovemouse_fuzzer/project.xml | 25 ++++ .../stubhandlemovemouse_fuzzer.cpp | 53 +++++++++ .../stubhandlemovemouse_fuzzer.h | 21 ++++ .../stubhandleongetdevice_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandleongetdevice_fuzzer/corpus/init | 14 +++ .../stubhandleongetdevice_fuzzer/project.xml | 25 ++++ .../stubhandleongetdevice_fuzzer.cpp | 53 +++++++++ .../stubhandleongetdevice_fuzzer.h | 21 ++++ .../stubhandleongetdeviceids_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../stubhandleongetdeviceids_fuzzer.cpp | 56 +++++++++ .../stubhandleongetdeviceids_fuzzer.h | 21 ++++ .../stubhandleonsupportkeys_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../stubhandleonsupportkeys_fuzzer.cpp | 61 ++++++++++ .../stubhandleonsupportkeys_fuzzer.h | 21 ++++ .../stubhandlepinchswitch_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlepinchswitch_fuzzer/corpus/init | 14 +++ .../stubhandlepinchswitch_fuzzer/project.xml | 25 ++++ .../stubhandlepinchswitch_fuzzer.cpp | 54 +++++++++ .../stubhandlepinchswitch_fuzzer.h | 21 ++++ .../stubhandlepointerevent_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlepointerevent_fuzzer/corpus/init | 14 +++ .../stubhandlepointerevent_fuzzer/project.xml | 25 ++++ .../stubhandlepointerevent_fuzzer.cpp | 59 ++++++++++ .../stubhandlepointerevent_fuzzer.h | 21 ++++ .../stubhandlepointerspeed_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlepointerspeed_fuzzer/corpus/init | 14 +++ .../stubhandlepointerspeed_fuzzer/project.xml | 25 ++++ .../stubhandlepointerspeed_fuzzer.cpp | 54 +++++++++ .../stubhandlepointerspeed_fuzzer.h | 21 ++++ 40 files changed, 1786 insertions(+) create mode 100644 test/fuzztest/stubhandlemarkprocessed_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlemarkprocessed_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlemarkprocessed_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.h create mode 100644 test/fuzztest/stubhandlemovemouse_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlemovemouse_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlemovemouse_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.h create mode 100644 test/fuzztest/stubhandleongetdevice_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleongetdevice_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleongetdevice_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.h create mode 100644 test/fuzztest/stubhandleongetdeviceids_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleongetdeviceids_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleongetdeviceids_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.h create mode 100644 test/fuzztest/stubhandleonsupportkeys_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleonsupportkeys_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleonsupportkeys_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.h create mode 100644 test/fuzztest/stubhandlepinchswitch_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlepinchswitch_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlepinchswitch_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.h create mode 100644 test/fuzztest/stubhandlepointerevent_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlepointerevent_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlepointerevent_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.h create mode 100644 test/fuzztest/stubhandlepointerspeed_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlepointerspeed_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlepointerspeed_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.h diff --git a/test/fuzztest/stubhandlemarkprocessed_fuzzer/BUILD.gn b/test/fuzztest/stubhandlemarkprocessed_fuzzer/BUILD.gn new file mode 100644 index 0000000000..bcf23c897b --- /dev/null +++ b/test/fuzztest/stubhandlemarkprocessed_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("StubHandleMarkProcessedFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlemarkprocessed_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 = [ "stubhandlemarkprocessed_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 + ":StubHandleMarkProcessedFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlemarkprocessed_fuzzer/corpus/init b/test/fuzztest/stubhandlemarkprocessed_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlemarkprocessed_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/stubhandlemarkprocessed_fuzzer/project.xml b/test/fuzztest/stubhandlemarkprocessed_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlemarkprocessed_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.cpp b/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.cpp new file mode 100644 index 0000000000..c527c9a373 --- /dev/null +++ b/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_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 "stubhandlemarkprocessed_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 StubHandleMarkProcessedFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t eventType = provider.ConsumeIntegral(); + int32_t eventId = provider.ConsumeIntegral(); + + MMIService::GetInstance()->MarkProcessed(eventType, eventId); +} +} // 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::StubHandleMarkProcessedFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.h b/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_fuzzer.h new file mode 100644 index 0000000000..df5fa8423c --- /dev/null +++ b/test/fuzztest/stubhandlemarkprocessed_fuzzer/stubhandlemarkprocessed_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 "stubhandlemarkprocessed_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlemovemouse_fuzzer/BUILD.gn b/test/fuzztest/stubhandlemovemouse_fuzzer/BUILD.gn new file mode 100644 index 0000000000..c90cb9215a --- /dev/null +++ b/test/fuzztest/stubhandlemovemouse_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("StubHandleMoveMouseFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlemovemouse_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 = [ "stubhandlemovemouse_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 + ":StubHandleMoveMouseFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlemovemouse_fuzzer/corpus/init b/test/fuzztest/stubhandlemovemouse_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlemovemouse_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/stubhandlemovemouse_fuzzer/project.xml b/test/fuzztest/stubhandlemovemouse_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlemovemouse_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.cpp b/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.cpp new file mode 100644 index 0000000000..33c5725180 --- /dev/null +++ b/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_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 "stubhandlemovemouse_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 StubHandleMoveMouseFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t offsetX = provider.ConsumeIntegral(); + int32_t offsetY = provider.ConsumeIntegral(); + + MMIService::GetInstance()->MoveMouseEvent(offsetX, offsetY); +} +} // 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::StubHandleMoveMouseFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.h b/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_fuzzer.h new file mode 100644 index 0000000000..31c299b581 --- /dev/null +++ b/test/fuzztest/stubhandlemovemouse_fuzzer/stubhandlemovemouse_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 "stubhandlemovemouse_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleongetdevice_fuzzer/BUILD.gn b/test/fuzztest/stubhandleongetdevice_fuzzer/BUILD.gn new file mode 100644 index 0000000000..13c9792dd7 --- /dev/null +++ b/test/fuzztest/stubhandleongetdevice_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("StubHandleOnGetDeviceFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleongetdevice_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 = [ "stubhandleongetdevice_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 + ":StubHandleOnGetDeviceFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleongetdevice_fuzzer/corpus/init b/test/fuzztest/stubhandleongetdevice_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleongetdevice_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/stubhandleongetdevice_fuzzer/project.xml b/test/fuzztest/stubhandleongetdevice_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleongetdevice_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.cpp b/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.cpp new file mode 100644 index 0000000000..8cc831e9b8 --- /dev/null +++ b/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_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 "stubhandleongetdevice_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 StubHandleOnGetDeviceFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t deviceId = provider.ConsumeIntegral(); + std::shared_ptr inputDevice = std::make_shared(); + + MMIService::GetInstance()->OnGetDevice(deviceId, inputDevice); +} +} // 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::StubHandleOnGetDeviceFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.h b/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_fuzzer.h new file mode 100644 index 0000000000..fd97b6169d --- /dev/null +++ b/test/fuzztest/stubhandleongetdevice_fuzzer/stubhandleongetdevice_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 "stubhandleongetdevice_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleongetdeviceids_fuzzer/BUILD.gn b/test/fuzztest/stubhandleongetdeviceids_fuzzer/BUILD.gn new file mode 100644 index 0000000000..462e1e421e --- /dev/null +++ b/test/fuzztest/stubhandleongetdeviceids_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("StubHandleOnGetDeviceIdsFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleongetdeviceids_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 = [ "stubhandleongetdeviceids_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 + ":StubHandleOnGetDeviceIdsFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleongetdeviceids_fuzzer/corpus/init b/test/fuzztest/stubhandleongetdeviceids_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleongetdeviceids_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/stubhandleongetdeviceids_fuzzer/project.xml b/test/fuzztest/stubhandleongetdeviceids_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleongetdeviceids_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.cpp b/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.cpp new file mode 100644 index 0000000000..21aaccbd8a --- /dev/null +++ b/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * 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 "stubhandleongetdeviceids_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 StubHandleOnGetDeviceIdsFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + std::vector ids = { + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral() + }; + + MMIService::GetInstance()->OnGetDeviceIds(ids); +} +} // 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::StubHandleOnGetDeviceIdsFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.h b/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_fuzzer.h new file mode 100644 index 0000000000..c0d75e0207 --- /dev/null +++ b/test/fuzztest/stubhandleongetdeviceids_fuzzer/stubhandleongetdeviceids_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 "stubhandleongetdeviceids_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleonsupportkeys_fuzzer/BUILD.gn b/test/fuzztest/stubhandleonsupportkeys_fuzzer/BUILD.gn new file mode 100644 index 0000000000..0855ec7537 --- /dev/null +++ b/test/fuzztest/stubhandleonsupportkeys_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("StubHandleOnSupportKeysFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleonsupportkeys_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 = [ "stubhandleonsupportkeys_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 + ":StubHandleOnSupportKeysFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleonsupportkeys_fuzzer/corpus/init b/test/fuzztest/stubhandleonsupportkeys_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleonsupportkeys_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/stubhandleonsupportkeys_fuzzer/project.xml b/test/fuzztest/stubhandleonsupportkeys_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleonsupportkeys_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.cpp b/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.cpp new file mode 100644 index 0000000000..ba9da6209f --- /dev/null +++ b/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.cpp @@ -0,0 +1,61 @@ +/* + * 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 "stubhandleonsupportkeys_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 StubHandleOnSupportKeysFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + int32_t deviceId = provider.ConsumeIntegral(); + std::vector keys = { + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral(), + provider.ConsumeIntegral() + }; + std::vector keystroke = { + provider.ConsumeBool(), + provider.ConsumeBool() + }; + + MMIService::GetInstance()->OnSupportKeys(deviceId, keys, keystroke); +} +} // 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::StubHandleOnSupportKeysFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.h b/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_fuzzer.h new file mode 100644 index 0000000000..ae7b4f76ae --- /dev/null +++ b/test/fuzztest/stubhandleonsupportkeys_fuzzer/stubhandleonsupportkeys_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 "stubhandleonsupportkeys_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlepinchswitch_fuzzer/BUILD.gn b/test/fuzztest/stubhandlepinchswitch_fuzzer/BUILD.gn new file mode 100644 index 0000000000..f28065f7f8 --- /dev/null +++ b/test/fuzztest/stubhandlepinchswitch_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("StubHandlePinchSwitchFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlepinchswitch_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 = [ "stubhandlepinchswitch_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 + ":StubHandlePinchSwitchFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlepinchswitch_fuzzer/corpus/init b/test/fuzztest/stubhandlepinchswitch_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlepinchswitch_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/stubhandlepinchswitch_fuzzer/project.xml b/test/fuzztest/stubhandlepinchswitch_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlepinchswitch_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.cpp b/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.cpp new file mode 100644 index 0000000000..4dabab460e --- /dev/null +++ b/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_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 "stubhandlepinchswitch_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 StubHandlePinchSwitchFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + bool switchFlag = provider.ConsumeBool(); + + MMIService::GetInstance()->SetTouchpadPinchSwitch(switchFlag); + MMIService::GetInstance()->ReadTouchpadPinchSwitch(switchFlag); + MMIService::GetInstance()->GetTouchpadPinchSwitch(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::StubHandlePinchSwitchFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.h b/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_fuzzer.h new file mode 100644 index 0000000000..6f0f55253d --- /dev/null +++ b/test/fuzztest/stubhandlepinchswitch_fuzzer/stubhandlepinchswitch_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 "stubhandlepinchswitch_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlepointerevent_fuzzer/BUILD.gn b/test/fuzztest/stubhandlepointerevent_fuzzer/BUILD.gn new file mode 100644 index 0000000000..e85a1b1e34 --- /dev/null +++ b/test/fuzztest/stubhandlepointerevent_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("StubHandlePointerEventFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlepointerevent_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 = [ "stubhandlepointerevent_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 + ":StubHandlePointerEventFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlepointerevent_fuzzer/corpus/init b/test/fuzztest/stubhandlepointerevent_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlepointerevent_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/stubhandlepointerevent_fuzzer/project.xml b/test/fuzztest/stubhandlepointerevent_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlepointerevent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.cpp b/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.cpp new file mode 100644 index 0000000000..e2ec57ce53 --- /dev/null +++ b/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.cpp @@ -0,0 +1,59 @@ +/* + * 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 "stubhandlepointerevent_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 StubHandlePointerEventFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + std::shared_ptr pointerEvent = PointerEvent::Create(); + pointerEvent->pointerAction_ = provider.ConsumeIntegral(); + pointerEvent->originPointerAction_ = provider.ConsumeIntegral(); + pointerEvent->buttonId_ = provider.ConsumeIntegral(); + pointerEvent->fingerCount_ = provider.ConsumeIntegral(); + pointerEvent->pullId_ = provider.ConsumeIntegral(); + bool isNativeInject = provider.ConsumeBool(); + int32_t useCoordinate = provider.ConsumeIntegral(); + + MMIService::GetInstance()->InjectPointerEvent(*pointerEvent.get(), isNativeInject, useCoordinate); +} +} // 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::StubHandlePointerEventFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.h b/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_fuzzer.h new file mode 100644 index 0000000000..83a3efa535 --- /dev/null +++ b/test/fuzztest/stubhandlepointerevent_fuzzer/stubhandlepointerevent_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 "stubhandlepointerevent_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlepointerspeed_fuzzer/BUILD.gn b/test/fuzztest/stubhandlepointerspeed_fuzzer/BUILD.gn new file mode 100644 index 0000000000..1ded793f5f --- /dev/null +++ b/test/fuzztest/stubhandlepointerspeed_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("StubHandlePointerSpeedFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlepointerspeed_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 = [ "stubhandlepointerspeed_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 + ":StubHandlePointerSpeedFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlepointerspeed_fuzzer/corpus/init b/test/fuzztest/stubhandlepointerspeed_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlepointerspeed_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/stubhandlepointerspeed_fuzzer/project.xml b/test/fuzztest/stubhandlepointerspeed_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlepointerspeed_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.cpp b/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.cpp new file mode 100644 index 0000000000..b0a4b2fcfb --- /dev/null +++ b/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_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 "stubhandlepointerspeed_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 StubHandlePointerSpeedFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t speed = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetTouchpadPointerSpeed(speed); + MMIService::GetInstance()->ReadTouchpadPointerSpeed(speed); + MMIService::GetInstance()->GetTouchpadPointerSpeed(speed); +} +} // 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::StubHandlePointerSpeedFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.h b/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_fuzzer.h new file mode 100644 index 0000000000..ac8676b577 --- /dev/null +++ b/test/fuzztest/stubhandlepointerspeed_fuzzer/stubhandlepointerspeed_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 "stubhandlepointerspeed_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H -- Gitee