diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 3d03d68a6c0b6467dfc324249d1845b6e129e1b4..bab8d9ac77d104bcf83ae52bcfc9defddd04b6d0 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 0000000000000000000000000000000000000000..f8cfb2638f608180cb335d42767ab2f71d971955 --- /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 e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 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 6d3e765c7dc1097ac2fb92d825dfad6b0b08636d..66e1dcac475475fb101b6f8670ec699e6e9696aa 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 0000000000000000000000000000000000000000..cb25cc9935ed10b23838984113627d29f40d48ea --- /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 0000000000000000000000000000000000000000..04b969dd3eb4d74c51557d5eb12ebdd107c1ca8d --- /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 0000000000000000000000000000000000000000..ed5f1c0cec10f56450125bd4c24620741ab732b3 --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..a3de434f75bdf4438be49726792befe05ee54a0f --- /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 63c96500abbfcc53e414a52285913ad09b73885d..e51280c374ecc52811f91827ce477fb903df14f2 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 0000000000000000000000000000000000000000..584faa315584fbda6cf99702424055311e78ae6f --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..9240fe8fcd2ba76a51407384e626e790a86b1b64 --- /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 0000000000000000000000000000000000000000..f2ce9e47a31c097ce1416b104673e120554b6cc4 --- /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 0000000000000000000000000000000000000000..ce80baeffd3bf867462eddc1267e22ed6278996a --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..d360b21317544fa0209bf9b738e0826f123d68e2 --- /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 0000000000000000000000000000000000000000..ba741ae9109f572468e9a32d39ce45f82209efdd --- /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 0000000000000000000000000000000000000000..6cd1034b20733fb8f4cae3aaa9abf895c983ce7c --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..460c7237cf4b278ddad2d54924086e16a15e4735 --- /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 0000000000000000000000000000000000000000..d3e4bb0654e9498e5e73cfb7394f8383813bac48 --- /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 0000000000000000000000000000000000000000..0d87a20eb385d72673b8fca3c38ec81599e0d211 --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..e936ab928cef04a88af2cdbd43e377e27b7fddc1 --- /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 0000000000000000000000000000000000000000..e2544bdd9db9f412cfd7569dbefd3931e95ed40f --- /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 0000000000000000000000000000000000000000..608aa15ca0359d6a34806e0f26de1070f78ea82c --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..529b22a88a2dc00424048486b9ff2f8bff7a754f --- /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 0000000000000000000000000000000000000000..2cdda4794f58ff37fcbaf406e2619b1587d56bfc --- /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 0000000000000000000000000000000000000000..4938ed00a4806e26a0b34191c9e067cd089995e7 --- /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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 0000000000000000000000000000000000000000..c259853100fca11f2dfcc6d2c610f4932eb6310a --- /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 0000000000000000000000000000000000000000..9b13f7176be9d989ba132f7e216e01eab4c49a84 --- /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 88e5921192620414385aa6bdbb8f311b479105c2..5916804690d03d6b61712271eebb4c65b2089e54 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 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791 --- /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 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa --- /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 5d95a2c3c9207bf97d10aae0b4172080ae5d2b14..50741b7066fbf41dca29e914d34c2f047f2be29c 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 0000000000000000000000000000000000000000..44c8c0e45965ffc103336032c813fb731a943070 --- /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