From a3bb7bc3f9c04427b90584bb58509fda241819a9 Mon Sep 17 00:00:00 2001 From: huxianghao Date: Sat, 13 Sep 2025 03:45:00 +0000 Subject: [PATCH] [test]:Modify fuzz stubhandle 1 Signed-off-by: huxianghao --- test/fuzztest/BUILD.gn | 2 +- .../stubhandleaddability_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 2 +- .../project.xml | 4 +- .../stubhandleaddability_fuzzer.cpp | 53 +++++++++ .../stubhandleaddability_fuzzer.h | 21 ++++ .../stubhandleaddepoll_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandleaddepoll_fuzzer/corpus/init | 14 +++ .../stubhandleaddepoll_fuzzer/project.xml | 25 ++++ .../stubhandleaddepoll_fuzzer.cpp | 53 +++++++++ .../stubhandleaddepoll_fuzzer.h} | 10 +- .../stubhandleaddvirtual_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandleaddvirtual_fuzzer/corpus/init | 14 +++ .../stubhandleaddvirtual_fuzzer/project.xml | 25 ++++ .../stubhandleaddvirtual_fuzzer.cpp | 64 +++++++++++ .../stubhandleaddvirtual_fuzzer.h | 21 ++++ .../stubhandlecheckinput_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlecheckinput_fuzzer/corpus/init | 14 +++ .../stubhandlecheckinput_fuzzer/project.xml | 25 ++++ .../stubhandlecheckinput_fuzzer.cpp | 57 +++++++++ .../stubhandlecheckinput_fuzzer.h | 21 ++++ .../stubhandleclicktype_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandleclicktype_fuzzer/corpus/init | 14 +++ .../stubhandleclicktype_fuzzer/project.xml | 25 ++++ .../stubhandleclicktype_fuzzer.cpp | 52 +++++++++ .../stubhandleclicktype_fuzzer.h | 21 ++++ .../stubhandlecurrentuser_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlecurrentuser_fuzzer/corpus/init | 14 +++ .../stubhandlecurrentuser_fuzzer/project.xml | 25 ++++ .../stubhandlecurrentuser_fuzzer.cpp | 52 +++++++++ .../stubhandlecurrentuser_fuzzer.h | 21 ++++ .../stubhandlecursorstats_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandlecursorstats_fuzzer/corpus/init | 14 +++ .../stubhandlecursorstats_fuzzer/project.xml | 25 ++++ .../stubhandlecursorstats_fuzzer.cpp | 55 +++++++++ .../stubhandlecursorstats_fuzzer.h | 21 ++++ .../stubhandledelepoll_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../stubhandledelepoll_fuzzer/corpus/init | 14 +++ .../stubhandledelepoll_fuzzer/project.xml | 25 ++++ .../stubhandledelepoll_fuzzer.cpp | 52 +++++++++ .../stubhandledelepoll_fuzzer.h | 21 ++++ .../BUILD.gn | 13 ++- .../stubhandledownduration_fuzzer/corpus/init | 14 +++ .../stubhandledownduration_fuzzer/project.xml | 25 ++++ .../stubhandledownduration_fuzzer.cpp} | 44 ++++--- .../stubhandledownduration_fuzzer.h | 21 ++++ 46 files changed, 1819 insertions(+), 38 deletions(-) create mode 100644 test/fuzztest/stubhandleaddability_fuzzer/BUILD.gn rename test/fuzztest/{stubsetkeydownduration_fuzzer => stubhandleaddability_fuzzer}/corpus/init (92%) rename test/fuzztest/{stubsetkeydownduration_fuzzer => stubhandleaddability_fuzzer}/project.xml (93%) create mode 100644 test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.h create mode 100644 test/fuzztest/stubhandleaddepoll_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleaddepoll_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleaddepoll_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.cpp rename test/fuzztest/{stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.h => stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.h} (71%) create mode 100644 test/fuzztest/stubhandleaddvirtual_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleaddvirtual_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleaddvirtual_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.h create mode 100644 test/fuzztest/stubhandlecheckinput_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlecheckinput_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlecheckinput_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.h create mode 100644 test/fuzztest/stubhandleclicktype_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandleclicktype_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandleclicktype_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.cpp create mode 100644 test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.h create mode 100644 test/fuzztest/stubhandlecurrentuser_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlecurrentuser_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlecurrentuser_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.h create mode 100644 test/fuzztest/stubhandlecursorstats_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandlecursorstats_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandlecursorstats_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.cpp create mode 100644 test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.h create mode 100644 test/fuzztest/stubhandledelepoll_fuzzer/BUILD.gn create mode 100644 test/fuzztest/stubhandledelepoll_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandledelepoll_fuzzer/project.xml create mode 100644 test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.cpp create mode 100644 test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.h rename test/fuzztest/{stubsetkeydownduration_fuzzer => stubhandledownduration_fuzzer}/BUILD.gn (89%) create mode 100644 test/fuzztest/stubhandledownduration_fuzzer/corpus/init create mode 100644 test/fuzztest/stubhandledownduration_fuzzer/project.xml rename test/fuzztest/{stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.cpp => stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp} (41%) create mode 100644 test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 3d03d68a6c..bab8d9ac77 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -222,7 +222,7 @@ group("test") { "stubsethoverscrollstate_fuzzer:fuzztest", "stubsetkeyboardrepeatdelay_fuzzer:fuzztest", "stubsetkeyboardrepeatrate_fuzzer:fuzztest", - "stubsetkeydownduration_fuzzer:fuzztest", + "stubhandledownduration_fuzzer:fuzztest", "stubsetmousecapturemode_fuzzer:fuzztest", "stubsetmousehotspot_fuzzer:fuzztest", "stubsetmouseicon_fuzzer:fuzztest", diff --git a/test/fuzztest/stubhandleaddability_fuzzer/BUILD.gn b/test/fuzztest/stubhandleaddability_fuzzer/BUILD.gn new file mode 100644 index 0000000000..f8cfb2638f --- /dev/null +++ b/test/fuzztest/stubhandleaddability_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("StubHandleAddAbilityFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleaddability_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 = [ "stubhandleaddability_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 + ":StubHandleAddAbilityFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubsetkeydownduration_fuzzer/corpus/init b/test/fuzztest/stubhandleaddability_fuzzer/corpus/init similarity index 92% rename from test/fuzztest/stubsetkeydownduration_fuzzer/corpus/init rename to test/fuzztest/stubhandleaddability_fuzzer/corpus/init index e7c3fecd8d..65af8ee8d1 100644 --- a/test/fuzztest/stubsetkeydownduration_fuzzer/corpus/init +++ b/test/fuzztest/stubhandleaddability_fuzzer/corpus/init @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# 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 diff --git a/test/fuzztest/stubsetkeydownduration_fuzzer/project.xml b/test/fuzztest/stubhandleaddability_fuzzer/project.xml similarity index 93% rename from test/fuzztest/stubsetkeydownduration_fuzzer/project.xml rename to test/fuzztest/stubhandleaddability_fuzzer/project.xml index 6d3e765c7d..66e1dcac47 100644 --- a/test/fuzztest/stubsetkeydownduration_fuzzer/project.xml +++ b/test/fuzztest/stubhandleaddability_fuzzer/project.xml @@ -1,5 +1,5 @@ - 4096 - \ No newline at end of file + diff --git a/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.cpp b/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.cpp new file mode 100644 index 0000000000..cb25cc9935 --- /dev/null +++ b/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_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 "stubhandleaddability_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 StubHandleAddAbilityFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t systemAbilityId = provider.ConsumeIntegral(); + std::string deviceId = provider.ConsumeBytesAsString(10); // test value + + MMIService::GetInstance()->OnAddSystemAbility(systemAbilityId, deviceId); +} +} // 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::StubHandleAddAbilityFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.h b/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_fuzzer.h new file mode 100644 index 0000000000..04b969dd3e --- /dev/null +++ b/test/fuzztest/stubhandleaddability_fuzzer/stubhandleaddability_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 "stubhandleaddability_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleaddepoll_fuzzer/BUILD.gn b/test/fuzztest/stubhandleaddepoll_fuzzer/BUILD.gn new file mode 100644 index 0000000000..ed5f1c0cec --- /dev/null +++ b/test/fuzztest/stubhandleaddepoll_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("StubHandleAddEpollFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleaddepoll_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 = [ "stubhandleaddepoll_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 + ":StubHandleAddEpollFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleaddepoll_fuzzer/corpus/init b/test/fuzztest/stubhandleaddepoll_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleaddepoll_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/stubhandleaddepoll_fuzzer/project.xml b/test/fuzztest/stubhandleaddepoll_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleaddepoll_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.cpp b/test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.cpp new file mode 100644 index 0000000000..a3de434f75 --- /dev/null +++ b/test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_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 "stubhandleaddepoll_fuzzer.h" + +#include "mmi_service.h" +#include "multimodal_input_connect_stub.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "StubHandleAddEpollFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; + +namespace OHOS { +namespace MMI { + +void StubHandleAddEpollFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + EpollEventType type = static_cast(provider.ConsumeIntegralInRange(0, EPOLL_EVENT_END)); + int32_t fd = provider.ConsumeIntegral(); + bool readOnly = provider.ConsumeBool(); + MMIService::GetInstance()->AddEpoll(type, fd, readOnly); +} + +} // 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::StubHandleAddEpollFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.h b/test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.h similarity index 71% rename from test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.h rename to test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.h index 63c96500ab..e51280c374 100644 --- a/test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.h +++ b/test/fuzztest/stubhandleaddepoll_fuzzer/stubhandleaddepoll_fuzzer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef STUBSETKEYDOWNDURATION_FUZZER_H -#define STUBSETKEYDOWNDURATION_FUZZER_H +#ifndef STUBHANDLEALLOCSOCAETFD_FUZZER_H +#define STUBHANDLEALLOCSOCAETFD_FUZZER_H -#define FUZZ_PROJECT_NAME "stubsetkeydownduration_fuzzer" +#define FUZZ_PROJECT_NAME "stubhandleaddepoll_fuzzer" -#endif // STUBSETKEYDOWNDURATION_FUZZER_H \ No newline at end of file +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleaddvirtual_fuzzer/BUILD.gn b/test/fuzztest/stubhandleaddvirtual_fuzzer/BUILD.gn new file mode 100644 index 0000000000..584faa3155 --- /dev/null +++ b/test/fuzztest/stubhandleaddvirtual_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("StubHandleAddVirtualFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleaddvirtual_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 = [ "stubhandleaddvirtual_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 + ":StubHandleAddVirtualFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleaddvirtual_fuzzer/corpus/init b/test/fuzztest/stubhandleaddvirtual_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleaddvirtual_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/stubhandleaddvirtual_fuzzer/project.xml b/test/fuzztest/stubhandleaddvirtual_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleaddvirtual_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.cpp b/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.cpp new file mode 100644 index 0000000000..9240fe8fcd --- /dev/null +++ b/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.cpp @@ -0,0 +1,64 @@ +/* + * 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 "stubhandleaddvirtual_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 { +namespace { +constexpr uint32_t MAX_BUNDLE_NAME_LENGTH = 127; +} // namespace + +void StubHandleAddVirtualFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t deviceId = provider.ConsumeIntegral(); + InputDevice device; + device.id_ = provider.ConsumeIntegral(); + device.type_ = provider.ConsumeIntegral(); + device.bus_ = provider.ConsumeIntegral(); + device.version_ = provider.ConsumeIntegral(); + device.product_ = provider.ConsumeIntegral(); + device.vendor_ = provider.ConsumeIntegral(); + device.phys_ = provider.ConsumeRandomLengthString(MAX_BUNDLE_NAME_LENGTH); + device.uniq_ = provider.ConsumeRandomLengthString(MAX_BUNDLE_NAME_LENGTH); + MMIService::GetInstance()->AddVirtualInputDevice(device, deviceId); + MMIService::GetInstance()->RemoveVirtualInputDevice(deviceId); +} +} // 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::StubHandleAddVirtualFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.h b/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_fuzzer.h new file mode 100644 index 0000000000..f2ce9e47a3 --- /dev/null +++ b/test/fuzztest/stubhandleaddvirtual_fuzzer/stubhandleaddvirtual_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 "stubhandleaddvirtual_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlecheckinput_fuzzer/BUILD.gn b/test/fuzztest/stubhandlecheckinput_fuzzer/BUILD.gn new file mode 100644 index 0000000000..ce80baeffd --- /dev/null +++ b/test/fuzztest/stubhandlecheckinput_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("StubHandleCheckInputFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlecheckinput_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 = [ "stubhandlecheckinput_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 + ":StubHandleCheckInputFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlecheckinput_fuzzer/corpus/init b/test/fuzztest/stubhandlecheckinput_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlecheckinput_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/stubhandlecheckinput_fuzzer/project.xml b/test/fuzztest/stubhandlecheckinput_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlecheckinput_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.cpp b/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.cpp new file mode 100644 index 0000000000..d360b21317 --- /dev/null +++ b/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.cpp @@ -0,0 +1,57 @@ +/* + * 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 "stubhandlecheckinput_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 StubHandleCheckInputFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t pid = provider.ConsumeIntegral(); + InputHandlerType handlerType = + static_cast(provider.ConsumeIntegralInRange(0, MONITOR)); + HandleEventType eventType = provider.ConsumeIntegral(); + int32_t priority = provider.ConsumeIntegral(); + uint32_t deviceTags = provider.ConsumeIntegral(); + + MMIService::GetInstance()->CheckRemoveInput(pid, 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::StubHandleCheckInputFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.h b/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_fuzzer.h new file mode 100644 index 0000000000..ba741ae910 --- /dev/null +++ b/test/fuzztest/stubhandlecheckinput_fuzzer/stubhandlecheckinput_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 "stubhandlecheckinput_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandleclicktype_fuzzer/BUILD.gn b/test/fuzztest/stubhandleclicktype_fuzzer/BUILD.gn new file mode 100644 index 0000000000..6cd1034b20 --- /dev/null +++ b/test/fuzztest/stubhandleclicktype_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("StubHandleClickTypeFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandleclicktype_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 = [ "stubhandleclicktype_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 + ":StubHandleClickTypeFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandleclicktype_fuzzer/corpus/init b/test/fuzztest/stubhandleclicktype_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandleclicktype_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/stubhandleclicktype_fuzzer/project.xml b/test/fuzztest/stubhandleclicktype_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandleclicktype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.cpp b/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.cpp new file mode 100644 index 0000000000..460c7237cf --- /dev/null +++ b/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_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 "stubhandleclicktype_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 StubHandleClickTypeFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t type = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetTouchpadRightClickType(type); +} +} // 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::StubHandleClickTypeFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.h b/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_fuzzer.h new file mode 100644 index 0000000000..d3e4bb0654 --- /dev/null +++ b/test/fuzztest/stubhandleclicktype_fuzzer/stubhandleclicktype_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 "stubhandleclicktype_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlecurrentuser_fuzzer/BUILD.gn b/test/fuzztest/stubhandlecurrentuser_fuzzer/BUILD.gn new file mode 100644 index 0000000000..0d87a20eb3 --- /dev/null +++ b/test/fuzztest/stubhandlecurrentuser_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("StubHandleCurrentUserFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlecurrentuser_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 = [ "stubhandlecurrentuser_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 + ":StubHandleCurrentUserFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlecurrentuser_fuzzer/corpus/init b/test/fuzztest/stubhandlecurrentuser_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlecurrentuser_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/stubhandlecurrentuser_fuzzer/project.xml b/test/fuzztest/stubhandlecurrentuser_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlecurrentuser_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.cpp b/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.cpp new file mode 100644 index 0000000000..e936ab928c --- /dev/null +++ b/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_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 "stubhandlecurrentuser_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 StubHandleCurrentUserFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + int32_t userId = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetCurrentUser(userId); +} +} // 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::StubHandleCurrentUserFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.h b/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_fuzzer.h new file mode 100644 index 0000000000..e2544bdd9d --- /dev/null +++ b/test/fuzztest/stubhandlecurrentuser_fuzzer/stubhandlecurrentuser_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 "stubhandlecurrentuser_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandlecursorstats_fuzzer/BUILD.gn b/test/fuzztest/stubhandlecursorstats_fuzzer/BUILD.gn new file mode 100644 index 0000000000..608aa15ca0 --- /dev/null +++ b/test/fuzztest/stubhandlecursorstats_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("StubHandleCursorStatsFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandlecursorstats_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 = [ "stubhandlecursorstats_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 + ":StubHandleCursorStatsFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandlecursorstats_fuzzer/corpus/init b/test/fuzztest/stubhandlecursorstats_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandlecursorstats_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/stubhandlecursorstats_fuzzer/project.xml b/test/fuzztest/stubhandlecursorstats_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandlecursorstats_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.cpp b/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.cpp new file mode 100644 index 0000000000..529b22a88a --- /dev/null +++ b/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_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 "stubhandlecursorstats_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 StubHandleCursorStatsFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + + bool enable = provider.ConsumeBool(); + uint32_t frameCount = provider.ConsumeIntegral(); + uint32_t vsyncCount = provider.ConsumeIntegral(); + + MMIService::GetInstance()->EnableHardwareCursorStats(enable); + MMIService::GetInstance()->GetHardwareCursorStats(frameCount, vsyncCount); +} +} // 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::StubHandleCursorStatsFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.h b/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_fuzzer.h new file mode 100644 index 0000000000..2cdda4794f --- /dev/null +++ b/test/fuzztest/stubhandlecursorstats_fuzzer/stubhandlecursorstats_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 "stubhandlecursorstats_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubhandledelepoll_fuzzer/BUILD.gn b/test/fuzztest/stubhandledelepoll_fuzzer/BUILD.gn new file mode 100644 index 0000000000..4938ed00a4 --- /dev/null +++ b/test/fuzztest/stubhandledelepoll_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("StubHandleDleEpollFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandledelepoll_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 = [ "stubhandledelepoll_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 + ":StubHandleDleEpollFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/stubhandledelepoll_fuzzer/corpus/init b/test/fuzztest/stubhandledelepoll_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandledelepoll_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/stubhandledelepoll_fuzzer/project.xml b/test/fuzztest/stubhandledelepoll_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandledelepoll_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.cpp b/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.cpp new file mode 100644 index 0000000000..c259853100 --- /dev/null +++ b/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_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 "stubhandledelepoll_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 StubHandleDelEpollFuzzTest(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + EpollEventType type = static_cast(provider.ConsumeIntegralInRange(0, EPOLL_EVENT_END)); + int32_t fd = provider.ConsumeIntegral(); + + MMIService::GetInstance()->DelEpoll(type, fd); +} +} // 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::StubHandleDelEpollFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.h b/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_fuzzer.h new file mode 100644 index 0000000000..9b13f7176b --- /dev/null +++ b/test/fuzztest/stubhandledelepoll_fuzzer/stubhandledelepoll_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 "stubhandledelepoll_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H diff --git a/test/fuzztest/stubsetkeydownduration_fuzzer/BUILD.gn b/test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn similarity index 89% rename from test/fuzztest/stubsetkeydownduration_fuzzer/BUILD.gn rename to test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn index 88e5921192..5916804690 100644 --- a/test/fuzztest/stubsetkeydownduration_fuzzer/BUILD.gn +++ b/test/fuzztest/stubhandledownduration_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# 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 @@ -18,9 +18,9 @@ import("../../../multimodalinput_mini.gni") module_output_path = "input/input" ##############################fuzztest########################################## -ohos_fuzztest("StubSetKeyDownDurationFuzzTest") { +ohos_fuzztest("StubHandleDownDurationFuzzTest") { module_out_path = module_output_path - fuzz_config_file = "${mmi_path}/test/fuzztest/stubsetkeydownduration_fuzzer" + fuzz_config_file = "${mmi_path}/test/fuzztest/stubhandledownduration_fuzzer" include_dirs = [ "${mmi_path}/interfaces/util/common/include", "${mmi_path}/service/connect_manager/include", @@ -42,6 +42,8 @@ ohos_fuzztest("StubSetKeyDownDurationFuzzTest") { "${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", @@ -58,10 +60,11 @@ ohos_fuzztest("StubSetKeyDownDurationFuzzTest") { "${mmi_path}/common/anco/comm:mmi_anco_channel_config", ] - sources = [ "stubsetkeydownduration_fuzzer.cpp" ] + sources = [ "stubhandledownduration_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", ] @@ -99,7 +102,7 @@ group("fuzztest") { deps = [] deps += [ # deps file - ":StubSetKeyDownDurationFuzzTest", + ":StubHandleDownDurationFuzzTest", ] } ############################################################################### diff --git a/test/fuzztest/stubhandledownduration_fuzzer/corpus/init b/test/fuzztest/stubhandledownduration_fuzzer/corpus/init new file mode 100644 index 0000000000..65af8ee8d1 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_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/stubhandledownduration_fuzzer/project.xml b/test/fuzztest/stubhandledownduration_fuzzer/project.xml new file mode 100644 index 0000000000..66e1dcac47 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.cpp b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp similarity index 41% rename from test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.cpp rename to test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp index 5d95a2c3c9..50741b7066 100644 --- a/test/fuzztest/stubsetkeydownduration_fuzzer/stubsetkeydownduration_fuzzer.cpp +++ b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 + * 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, @@ -13,45 +13,41 @@ * limitations under the License. */ -#include "stubsetkeydownduration_fuzzer.h" +#include +#include "stubhandledownduration_fuzzer.h" -#include "mmi_log.h" #include "mmi_service.h" #include "multimodal_input_connect_stub.h" #undef MMI_LOG_TAG -#define MMI_LOG_TAG "StubSetKeyDownDurationFuzzTest" +#define MMI_LOG_TAG "StubHandleAllocSocketFdFuzzTest" + +class UDSSession; +using SessionPtr = std::shared_ptr; namespace OHOS { namespace MMI { -namespace OHOS { -bool StubSetKeyDownDurationFuzzTest(const uint8_t* data, size_t size) +void StubHandleDownDurationFuzzTest(const uint8_t *data, size_t size) { - const std::u16string FORMMGR_INTERFACE_TOKEN = IMultimodalInputConnect::GetDescriptor(); - MessageParcel datas; - if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN) || - !datas.WriteBuffer(data, size) || !datas.RewindRead(0)) { - return false; - } - MessageParcel reply; - MessageOption option; - MMIService::GetInstance()->state_ = ServiceRunningState::STATE_RUNNING; - MMIService::GetInstance()->OnRemoteRequest( - static_cast(IMultimodalInputConnectIpcCode::COMMAND_SET_KEY_DOWN_DURATION), datas, reply, option); - return true; + FuzzedDataProvider provider(data, size); + + std::string businessId = provider.ConsumeBytesAsString(10); // test value + int32_t delay = provider.ConsumeIntegral(); + + MMIService::GetInstance()->SetKeyDownDuration(businessId, delay); } -} // namespace OHOS +} // MMI +} // OHOS -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +/* 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::StubSetKeyDownDurationFuzzTest(data, size); + OHOS::MMI::StubHandleDownDurationFuzzTest(data, size); return 0; } -} // namespace MMI -} // namespace OHOS \ No newline at end of file diff --git a/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_fuzzer.h new file mode 100644 index 0000000000..44c8c0e459 --- /dev/null +++ b/test/fuzztest/stubhandledownduration_fuzzer/stubhandledownduration_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 "stubhandledownduration_fuzzer" + +#endif // STUBHANDLEALLOCSOCAETFD_FUZZER_H -- Gitee