From b4ed99b11dc3cc467b434f3c901433515128ffcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Sat, 6 Sep 2025 15:47:59 +0800 Subject: [PATCH] =?UTF-8?q?Signed-off-by:=20=E4=B9=BE=E9=98=B3=E7=86=A0=20?= =?UTF-8?q??= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update --- test/fuzztest/BUILD.gn | 240 ++++++++++++++++++ .../convertmicrosecondtosecond_fuzzer.cpp | 48 ++++ .../convertmicrosecondtosecond_fuzzer.h | 20 ++ .../corpus/init | 16 ++ .../project.xml | 25 ++ .../setbootcompleted_fuzzer/corpus/init | 16 ++ .../setbootcompleted_fuzzer/project.xml | 25 ++ .../setbootcompleted_fuzzer.cpp | 46 ++++ .../setbootcompleted_fuzzer.h | 20 ++ test/fuzztest/stringtoint_fuzzer/corpus/init | 16 ++ test/fuzztest/stringtoint_fuzzer/project.xml | 25 ++ .../stringtoint_fuzzer/stringtoint_fuzzer.cpp | 47 ++++ .../stringtoint_fuzzer/stringtoint_fuzzer.h | 20 ++ test/fuzztest/stringtoll_fuzzer/corpus/init | 16 ++ test/fuzztest/stringtoll_fuzzer/project.xml | 25 ++ .../stringtoll_fuzzer/stringtoll_fuzzer.cpp | 47 ++++ .../stringtoll_fuzzer/stringtoll_fuzzer.h | 20 ++ test/fuzztest/stringtouint_fuzzer/corpus/init | 16 ++ test/fuzztest/stringtouint_fuzzer/project.xml | 25 ++ .../stringtouint_fuzzer.cpp | 47 ++++ .../stringtouint_fuzzer/stringtouint_fuzzer.h | 20 ++ test/fuzztest/stringtoull_fuzzer/corpus/init | 16 ++ test/fuzztest/stringtoull_fuzzer/project.xml | 25 ++ .../stringtoull_fuzzer/stringtoull_fuzzer.cpp | 47 ++++ .../stringtoull_fuzzer/stringtoull_fuzzer.h | 20 ++ test/fuzztest/trimhead_fuzzer/corpus/init | 16 ++ test/fuzztest/trimhead_fuzzer/project.xml | 25 ++ .../trimhead_fuzzer/trimhead_fuzzer.cpp | 59 +++++ .../trimhead_fuzzer/trimhead_fuzzer.h | 20 ++ test/fuzztest/trimtail_fuzzer/corpus/init | 16 ++ test/fuzztest/trimtail_fuzzer/project.xml | 25 ++ .../trimtail_fuzzer/trimtail_fuzzer.cpp | 59 +++++ .../trimtail_fuzzer/trimtail_fuzzer.h | 20 ++ .../watchparameter_fuzzer.cpp | 5 - 34 files changed, 1128 insertions(+), 5 deletions(-) create mode 100644 test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.cpp create mode 100644 test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.h create mode 100644 test/fuzztest/convertmicrosecondtosecond_fuzzer/corpus/init create mode 100644 test/fuzztest/convertmicrosecondtosecond_fuzzer/project.xml create mode 100644 test/fuzztest/setbootcompleted_fuzzer/corpus/init create mode 100644 test/fuzztest/setbootcompleted_fuzzer/project.xml create mode 100644 test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.cpp create mode 100644 test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.h create mode 100644 test/fuzztest/stringtoint_fuzzer/corpus/init create mode 100644 test/fuzztest/stringtoint_fuzzer/project.xml create mode 100644 test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.cpp create mode 100644 test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.h create mode 100644 test/fuzztest/stringtoll_fuzzer/corpus/init create mode 100644 test/fuzztest/stringtoll_fuzzer/project.xml create mode 100644 test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.cpp create mode 100644 test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.h create mode 100644 test/fuzztest/stringtouint_fuzzer/corpus/init create mode 100644 test/fuzztest/stringtouint_fuzzer/project.xml create mode 100644 test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.cpp create mode 100644 test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.h create mode 100644 test/fuzztest/stringtoull_fuzzer/corpus/init create mode 100644 test/fuzztest/stringtoull_fuzzer/project.xml create mode 100644 test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.cpp create mode 100644 test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.h create mode 100644 test/fuzztest/trimhead_fuzzer/corpus/init create mode 100644 test/fuzztest/trimhead_fuzzer/project.xml create mode 100644 test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.cpp create mode 100644 test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.h create mode 100644 test/fuzztest/trimtail_fuzzer/corpus/init create mode 100644 test/fuzztest/trimtail_fuzzer/project.xml create mode 100644 test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.cpp create mode 100644 test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.h diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index b21736520..5f3ffa1de 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -3420,6 +3420,238 @@ ohos_fuzztest("SplitStringFuzzTest") { defines = [ "STARTUP_INIT_TEST" ] } +ohos_fuzztest("SetBootCompletedFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/setbootcompleted_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "setbootcompleted_fuzzer/setbootcompleted_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("ConvertMicrosecondToSecondFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/convertmicrosecondtosecond_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("StringToLLFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/stringtoll_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "stringtoll_fuzzer/stringtoll_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("StringToULLFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/stringtoull_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "stringtoull_fuzzer/stringtoull_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("StringToIntFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/stringtoint_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "stringtoint_fuzzer/stringtoint_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("StringToUintFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/stringtouint_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "stringtouint_fuzzer/stringtouint_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("TrimHeadFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/trimhead_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "trimhead_fuzzer/trimhead_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("TrimTailFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/trimtail_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/services/param:parameter", + "//base/startup/init/services/utils:libinit_utils", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "hilog:libhilog", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "trimtail_fuzzer/trimtail_fuzzer.cpp" ] + + defines = [ "STARTUP_INIT_TEST" ] +} + ohos_fuzztest("SendLocalChangeFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//base/startup/init/test/fuzztest/sendlocalchange_fuzzer" @@ -3690,6 +3922,7 @@ group("fuzztest") { ":CheckAppWatchPermissionFuzzTest", ":CmdClientInitFuzzTest", ":CmdServiceProcessDelClientFuzzTest", + ":ConvertMicrosecondToSecondFuzzTest", ":DecodeGidFuzzTest", ":DecodeUidFuzzTest", ":DelRemoteWatcherFuzzTest", @@ -3783,15 +4016,22 @@ group("fuzztest") { ":ServiceSetReadyFuzzTest", ":ServiceWaitForStatusFuzzTest", ":ServiceWatchForStatusFuzzTest", + ":SetBootCompletedFuzzTest", ":SetParameterCFuzzTest", ":SetParameterCppFuzzTest", ":SplitStringFuzzTest", ":StartServiceByTimerFuzzTest", ":StopServiceTimerFuzzTest", + ":StringToIntFuzzTest", + ":StringToLLFuzzTest", + ":StringToUintFuzzTest", + ":StringToULLFuzzTest", ":SysCheckParamExistFuzzTest", ":SystemDumpParametersFuzzTest", ":SystemTraversalParameterFuzzTest", ":SystemWaitParameterFuzzTest", + ":TrimHeadFuzzTest", + ":TrimTailFuzzTest", ":UmountAllWithFstabFileFuzzTest", ":WaitParameterFuzzTest", ":WatchParameterFuzzTest", diff --git a/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.cpp b/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.cpp new file mode 100644 index 000000000..5c23aac94 --- /dev/null +++ b/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "init_utils.h" +#include "convertmicrosecondtosecond_fuzzer.h" +#include "securec.h" + +extern "C" { +float ConvertMicrosecondToSecond(int x); +} +namespace OHOS { + bool FuzzConvertMicrosecondToSecond(const uint8_t* data, size_t size) + { + if (data == nullptr || size < sizeof(int)) { + return false; + } + + int value = 0; + errno_t err = memcpy_s(&value, sizeof(value), data, sizeof(value)); + if (err != 0) { + return false; + } + + float ret = ConvertMicrosecondToSecond(value); + return ret != 0; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzConvertMicrosecondToSecond(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.h b/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.h new file mode 100644 index 000000000..6a37878fd --- /dev/null +++ b/test/fuzztest/convertmicrosecondtosecond_fuzzer/convertmicrosecondtosecond_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_CONVERT_MICROSECONDE_TO_SECONDE_FUZZER_H +#define TEST_FUZZTEST_CONVERT_MICROSECONDE_TO_SECONDE_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "convertmicrosecondtosecond_fuzzer" +#endif diff --git a/test/fuzztest/convertmicrosecondtosecond_fuzzer/corpus/init b/test/fuzztest/convertmicrosecondtosecond_fuzzer/corpus/init new file mode 100644 index 000000000..8920b50aa --- /dev/null +++ b/test/fuzztest/convertmicrosecondtosecond_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 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/convertmicrosecondtosecond_fuzzer/project.xml b/test/fuzztest/convertmicrosecondtosecond_fuzzer/project.xml new file mode 100644 index 000000000..9e35ed57f --- /dev/null +++ b/test/fuzztest/convertmicrosecondtosecond_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/setbootcompleted_fuzzer/corpus/init b/test/fuzztest/setbootcompleted_fuzzer/corpus/init new file mode 100644 index 000000000..8920b50aa --- /dev/null +++ b/test/fuzztest/setbootcompleted_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 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/setbootcompleted_fuzzer/project.xml b/test/fuzztest/setbootcompleted_fuzzer/project.xml new file mode 100644 index 000000000..9e35ed57f --- /dev/null +++ b/test/fuzztest/setbootcompleted_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.cpp b/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.cpp new file mode 100644 index 000000000..f0bc1bb46 --- /dev/null +++ b/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "init_utils.h" +#include "setbootcompleted_fuzzer.h" + + +namespace OHOS { + bool FuzzSetBootCompleted(const uint8_t* data, size_t size) + { + if (size == 0) { + return false; + } + bool ret = false; + bool shouldSet = (data[0] != 0); + bool original = IsBootCompleted(); + + SetBootCompleted(shouldSet); + if (IsBootCompleted() == shouldSet) { + ret = true; + } + SetBootCompleted(original); + return ret; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzSetBootCompleted(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.h b/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.h new file mode 100644 index 000000000..6302c1b78 --- /dev/null +++ b/test/fuzztest/setbootcompleted_fuzzer/setbootcompleted_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_SET_BOOT_COMPLETED_FUZZER_H +#define TEST_FUZZTEST_SET_BOOT_COMPLETED_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "setbootcompleted_fuzzer" +#endif diff --git a/test/fuzztest/stringtoint_fuzzer/corpus/init b/test/fuzztest/stringtoint_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/stringtoint_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/stringtoint_fuzzer/project.xml b/test/fuzztest/stringtoint_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/stringtoint_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.cpp b/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.cpp new file mode 100644 index 000000000..9ea6f71f8 --- /dev/null +++ b/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "init_utils.h" +#include "securec.h" +#include "stringtoint_fuzzer.h" + + +namespace OHOS { + bool FuzzStringToInt(const uint8_t* data, size_t size) + { + if (size < sizeof(int)) { + return false; + } + + int extractedInt = 0; + errno_t err = memcpy_s(&extractedInt, sizeof(extractedInt), data, sizeof(int)); + if (err != 0) { + return false; + } + std::string num = std::to_string(std::abs(extractedInt)); + int value = 0; + StringToInt(num.c_str(), value); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzStringToInt(data, size); + return 0; +} diff --git a/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.h b/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.h new file mode 100644 index 000000000..f6c5c16e8 --- /dev/null +++ b/test/fuzztest/stringtoint_fuzzer/stringtoint_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_STRING_TO_INT_FUZZER_H +#define TEST_FUZZTEST_STRING_TO_INT_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "stringtoint_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/stringtoll_fuzzer/corpus/init b/test/fuzztest/stringtoll_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/stringtoll_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/stringtoll_fuzzer/project.xml b/test/fuzztest/stringtoll_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/stringtoll_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.cpp b/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.cpp new file mode 100644 index 000000000..fe4faa550 --- /dev/null +++ b/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "init_utils.h" +#include "securec.h" +#include "stringtoll_fuzzer.h" + + +namespace OHOS { + bool FuzzStringToLL(const uint8_t* data, size_t size) + { + if (size < sizeof(int)) { + return false; + } + + int extractedInt = 0; + errno_t err = memcpy_s(&extractedInt, sizeof(extractedInt), data, sizeof(int)); + if (err != 0) { + return false; + } + std::string num = std::to_string(std::abs(extractedInt)); + long long int value = 0; + StringToLL(num.c_str(), &value); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzStringToLL(data, size); + return 0; +} diff --git a/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.h b/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.h new file mode 100644 index 000000000..495c46189 --- /dev/null +++ b/test/fuzztest/stringtoll_fuzzer/stringtoll_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_STRING_TO_LL_FUZZER_H +#define TEST_FUZZTEST_STRING_TO_LL_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "stringtoll_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/stringtouint_fuzzer/corpus/init b/test/fuzztest/stringtouint_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/stringtouint_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/stringtouint_fuzzer/project.xml b/test/fuzztest/stringtouint_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/stringtouint_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.cpp b/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.cpp new file mode 100644 index 000000000..369bcd472 --- /dev/null +++ b/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "init_utils.h" +#include "securec.h" +#include "stringtouint_fuzzer.h" + + +namespace OHOS { + bool FuzzStringToUint(const uint8_t* data, size_t size) + { + if (size < sizeof(int)) { + return false; + } + + int extractedInt = 0; + errno_t err = memcpy_s(&extractedInt, sizeof(extractedInt), data, sizeof(int)); + if (err != 0) { + return false; + } + std::string num = std::to_string(std::abs(extractedInt)); + unsigned int value = 0; + StringToUint(num.c_str(), &value); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzStringToUint(data, size); + return 0; +} diff --git a/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.h b/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.h new file mode 100644 index 000000000..8034eb1d1 --- /dev/null +++ b/test/fuzztest/stringtouint_fuzzer/stringtouint_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_STRING_TO_UINT_FUZZER_H +#define TEST_FUZZTEST_STRING_TO_UINT_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "stringtouint_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/stringtoull_fuzzer/corpus/init b/test/fuzztest/stringtoull_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/stringtoull_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/stringtoull_fuzzer/project.xml b/test/fuzztest/stringtoull_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/stringtoull_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.cpp b/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.cpp new file mode 100644 index 000000000..1e0f42ea5 --- /dev/null +++ b/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "init_utils.h" +#include "securec.h" +#include "stringtoull_fuzzer.h" + + +namespace OHOS { + bool FuzzStringToULL(const uint8_t* data, size_t size) + { + if (size < sizeof(int)) { + return false; + } + + int extractedInt = 0; + errno_t err = memcpy_s(&extractedInt, sizeof(extractedInt), data, sizeof(int)); + if (err != 0) { + return false; + } + std::string num = std::to_string(std::abs(extractedInt)); + unsigned long long int value = 0; + StringToULL(num.c_str(), &value); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzStringToULL(data, size); + return 0; +} diff --git a/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.h b/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.h new file mode 100644 index 000000000..9ba34f71e --- /dev/null +++ b/test/fuzztest/stringtoull_fuzzer/stringtoull_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_STRING_TO_ULL_FUZZER_H +#define TEST_FUZZTEST_STRING_TO_ULL_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "stringtoull_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/trimhead_fuzzer/corpus/init b/test/fuzztest/trimhead_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/trimhead_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/trimhead_fuzzer/project.xml b/test/fuzztest/trimhead_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/trimhead_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.cpp b/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.cpp new file mode 100644 index 000000000..c46772a6b --- /dev/null +++ b/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "init_utils.h" +#include "securec.h" +#include "trimhead_fuzzer.h" +static const int MIN_CHARECTER = 32; +static const int MAX_CHARECTER = 126; + +namespace OHOS { + std::vector CreateSafeString(const uint8_t* data, size_t size) + { + if (size == 0) { + return {'\0'}; + } + + std::vector safeStr(size + 1); + for (size_t i = 0; i < size; ++i) { + safeStr[i] = (data[i] >= MIN_CHARECTER && data[i] <= MAX_CHARECTER) ? data[i] : 'a'; + } + safeStr[size] = '\0'; + return safeStr; + } + + bool FuzzTrimHead(const uint8_t* data, size_t size) + { + if (size == 0) { + return false; + } + + auto safeStr = CreateSafeString(data, size); + char* str = safeStr.data(); + char trimChar = (size > 0 && data[0] >= MIN_CHARECTER && data[0] <= MAX_CHARECTER) ? data[0] : 'a'; + TrimHead(str, trimChar); + + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzTrimHead(data, size); + return 0; +} diff --git a/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.h b/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.h new file mode 100644 index 000000000..6787380f9 --- /dev/null +++ b/test/fuzztest/trimhead_fuzzer/trimhead_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_TRIM_HEAD_FUZZER_H +#define TEST_FUZZTEST_TRIM_HEAD_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "trimhead_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/trimtail_fuzzer/corpus/init b/test/fuzztest/trimtail_fuzzer/corpus/init new file mode 100644 index 000000000..9e55ceefe --- /dev/null +++ b/test/fuzztest/trimtail_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/trimtail_fuzzer/project.xml b/test/fuzztest/trimtail_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/trimtail_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.cpp b/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.cpp new file mode 100644 index 000000000..c41c80264 --- /dev/null +++ b/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "init_utils.h" +#include "securec.h" +#include "trimtail_fuzzer.h" +static const int MIN_CHARECTER = 32; +static const int MAX_CHARECTER = 126; + +namespace OHOS { + std::vector CreateSafeString(const uint8_t* data, size_t size) + { + if (size == 0) { + return {'\0'}; + } + + std::vector safeStr(size + 1); + for (size_t i = 0; i < size; ++i) { + safeStr[i] = (data[i] >= MIN_CHARECTER && data[i] <= MAX_CHARECTER) ? data[i] : 'a'; + } + safeStr[size] = '\0'; + return safeStr; + } + + bool FuzzTrimTail(const uint8_t* data, size_t size) + { + if (size == 0) { + return false; + } + + auto safeStr = CreateSafeString(data, size); + char* str = safeStr.data(); + char trimChar = (size > 0 && data[0] >= MIN_CHARECTER && data[0] <= MAX_CHARECTER) ? data[0] : 'a'; + TrimTail(str, trimChar); + + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzTrimTail(data, size); + return 0; +} diff --git a/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.h b/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.h new file mode 100644 index 000000000..4e5248679 --- /dev/null +++ b/test/fuzztest/trimtail_fuzzer/trimtail_fuzzer.h @@ -0,0 +1,20 @@ +/* + * 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 TEST_FUZZTEST_TRIM_TAIL_FUZZER_H +#define TEST_FUZZTEST_TRIM_TAIL_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "trimtail_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp index 39d0fdf4c..8889249d3 100644 --- a/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp +++ b/test/fuzztest/watchparameter_fuzzer/watchparameter_fuzzer.cpp @@ -17,8 +17,6 @@ #include #include "parameter.h" #include "fuzz_utils.h" -#include -static const int SLEEP_TIME = 100000; static void HandleParamChange(const char *key, const char *value, void *context) { @@ -31,13 +29,10 @@ static void HandleParamChange(const char *key, const char *value, void *context) namespace OHOS { bool FuzzWatchParameter(const uint8_t* data, size_t size) { - usleep(SLEEP_TIME); bool result = false; std::string str(reinterpret_cast(data), size); CloseStdout(); if (!WatchParameter(str.c_str(), HandleParamChange, NULL)) { - usleep(SLEEP_TIME); - WatchParameter(str.c_str(), NULL, NULL); result = true; } return result; -- Gitee