mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-26 06:18:10 +00:00
!2762 add softbus fuzz test
Merge pull request !2762 from libaoping28/master
This commit is contained in:
commit
06f2e69f20
@ -14,7 +14,16 @@
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [
|
||||
"bindparatext_fuzzer:BindParaTextFuzzTest",
|
||||
"convertbtmactobinary_fuzzer:ConvertBtMacToBinaryFuzztest",
|
||||
"convertbtmactostr_fuzzer:ConvertBtMacToStrFuzztest",
|
||||
"converthexstringtobytes_fuzzer:ConvertHexStringToBytesfuzztest",
|
||||
"encrypteddb_fuzzer:EncryptedDbFuzzTest",
|
||||
"insertrecord_fuzzer:InsertRecordFuzzTest",
|
||||
"removeallrecord_fuzzer:RemoveAllRecordFuzzTest",
|
||||
"removerecordbykey_fuzzer:RemoveRecordByKeyFuzzTest",
|
||||
"softbusutils_fuzzer:SoftBusUtilsFuzzTest",
|
||||
"sqlite3utils_fuzzer:Sqlite3UntilsFuzzTest",
|
||||
"updatedbpassword_fuzzer:UpdateDbPasswordFuzzTest",
|
||||
]
|
||||
}
|
||||
|
40
tests/core/common/utils/fuzztest/bindparatext_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/bindparatext_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("BindParaTextFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/bindparatext_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "bindparatext_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
44
tests/core/common/utils/fuzztest/bindparatext_fuzzer/bindparatext_fuzzer.cpp
Executable file
44
tests/core/common/utils/fuzztest/bindparatext_fuzzer/bindparatext_fuzzer.cpp
Executable file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "bindparatext_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
int32_t idx = 0;
|
||||
BindParaText(ctx, idx, (const char *)data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
21
tests/core/common/utils/fuzztest/bindparatext_fuzzer/bindparatext_fuzzer.h
Executable file
21
tests/core/common/utils/fuzztest/bindparatext_fuzzer/bindparatext_fuzzer.h
Executable file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_BINDPARATEXT_FUZZER_H
|
||||
#define TEST_FUZZTEST_BINDPARATEXT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "bindparatext_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_BINDPARATEXT_FUZZER_H */
|
15
tests/core/common/utils/fuzztest/bindparatext_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/bindparatext_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/bindparatext_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/bindparatext_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
34
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/BUILD.gn
Executable file
34
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("ConvertBtMacToBinaryFuzztest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/core/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "convertbtmactobinary_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "convertbtmactobinary_fuzzer.h"
|
||||
#include "softbus_utils.h"
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include "securec.h"
|
||||
#include "softbus_adapter_crypto.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_adapter_thread.h"
|
||||
#include "softbus_adapter_timer.h"
|
||||
#include "softbus_common.h"
|
||||
#include "softbus_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
uint8_t *binMac = nullptr;
|
||||
ConvertBtMacToBinary((const char *)rawData, size, binMac, size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_CONVERTBTMACTOBINARY_FUZZER_H
|
||||
#define TEST_FUZZTEST_CONVERTBTMACTOBINARY_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "convertbtmactobinary_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_CONVERTBTMACTOBINARY_FUZZER_H */
|
15
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/convertbtmactobinary_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>60</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>120</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>2048</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
34
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/BUILD.gn
Executable file
34
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("ConvertBtMacToStrFuzztest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/core/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "convertbtmactostr_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "convertbtmactostr_fuzzer.h"
|
||||
#include "softbus_utils.h"
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include "securec.h"
|
||||
#include "softbus_adapter_crypto.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_adapter_thread.h"
|
||||
#include "softbus_adapter_timer.h"
|
||||
#include "softbus_common.h"
|
||||
#include "softbus_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
char binMac[64] = {0};
|
||||
ConvertBtMacToStr(binMac, size, rawData, size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_CONVERTBTMACTOSTR_FUZZER_H
|
||||
#define TEST_FUZZTEST_CONVERTBTMACTOSTR_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "convertbtmactostr_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_CONVERTBTMACTOSTR_FUZZER_H */
|
15
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/convertbtmactostr_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>60</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>120</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>2048</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
34
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/BUILD.gn
Executable file
34
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("ConvertHexStringToBytesfuzztest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/core/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "converthexstringtobytes_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "converthexstringtobytes_fuzzer.h"
|
||||
#include "softbus_utils.h"
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include "securec.h"
|
||||
#include "softbus_adapter_crypto.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_adapter_thread.h"
|
||||
#include "softbus_adapter_timer.h"
|
||||
#include "softbus_common.h"
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_type_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
if (rawData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
unsigned char *outBuf = nullptr;
|
||||
ConvertHexStringToBytes(outBuf, size, (const char *)rawData, size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_REGISTERTIMEOUTCALLBACK_FUZZER_H
|
||||
#define TEST_FUZZTEST_REGISTERTIMEOUTCALLBACK_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "registertimeoutcallback_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_REGISTERTIMEOUTCALLBACK_FUZZER_H */
|
15
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/converthexstringtobytes_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>60</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>120</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>2048</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
40
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("EncryptedDbFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/encrypteddb_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "encrypteddb_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
46
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/encrypteddb_fuzzer.cpp
Executable file
46
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/encrypteddb_fuzzer.cpp
Executable file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "encrypteddb_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
EncryptedDb(ctx, data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
21
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/encrypteddb_fuzzer.h
Executable file
21
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/encrypteddb_fuzzer.h
Executable file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_ENCRYPTEDDB_FUZZER_H
|
||||
#define TEST_FUZZTEST_ENCRYPTEDDB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "encrypteddb_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_ENCRYPTEDDB_FUZZER_H */
|
25
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/encrypteddb_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
40
tests/core/common/utils/fuzztest/insertrecord_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/insertrecord_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("InsertRecordFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/insertrecord_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "insertrecord_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/core/common/utils/fuzztest/insertrecord_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/insertrecord_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
47
tests/core/common/utils/fuzztest/insertrecord_fuzzer/insertrecord_fuzzer.cpp
Executable file
47
tests/core/common/utils/fuzztest/insertrecord_fuzzer/insertrecord_fuzzer.cpp
Executable file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "insertrecord_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool InsertRecordFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
InsertRecord(ctx, TABLE_TRUSTED_DEV_INFO, (uint8_t *)data);
|
||||
InsertRecord(ctx, TABLE_NAME_ID_MAX, (uint8_t *)data);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::InsertRecordFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
tests/core/common/utils/fuzztest/insertrecord_fuzzer/insertrecord_fuzzer.h
Executable file
21
tests/core/common/utils/fuzztest/insertrecord_fuzzer/insertrecord_fuzzer.h
Executable file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_INSERTRECODE_FUZZER_H
|
||||
#define TEST_FUZZTEST_INSERTRECODE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "insertrecord_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_INSERTRECODE_FUZZER_H */
|
25
tests/core/common/utils/fuzztest/insertrecord_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/insertrecord_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
40
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("RemoveAllRecordFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/removeallrecord_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "removeallrecord_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/removeallrecord_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "removeallrecord_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include "softbus_adapter_mem.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
RemoveAllRecord(ctx, TABLE_TRUSTED_DEV_INFO);
|
||||
RemoveAllRecord(ctx, TABLE_NAME_ID_MAX);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_REMOVEALLRECORD_FUZZER_H
|
||||
#define TEST_FUZZTEST_REMOVEALLRECORD_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "removeallrecord_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_REMOVEALLRECORD_FUZZER_H */
|
40
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("RemoveRecordByKeyFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/removerecordbykey_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "removerecordbykey_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/removerecordbykey_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "removerecordbykey_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include "softbus_adapter_mem.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool RemoveRecordByKeyFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
RemoveRecordByKey(ctx, TABLE_TRUSTED_DEV_INFO, (uint8_t *)data);
|
||||
RemoveRecordByKey(ctx, TABLE_NAME_ID_MAX, (uint8_t *)data);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::RemoveRecordByKeyFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_REMOVERECORDBYKEY_FUZZER_H
|
||||
#define TEST_FUZZTEST_REMOVERECORDBYKEY_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "removerecordbykey_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_REMOVERECORDBYKEY_FUZZER_H */
|
40
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/BUILD.gn
Executable file
40
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/common"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("UpdateDbPasswordFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/core/common/utils/fuzztest/updatedbpassword_fuzzer"
|
||||
include_dirs = [ "$dsoftbus_root_path/adapter/common/include" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "updatedbpassword_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/core/common:softbus_utils" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/corpus/init
Executable file
15
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/project.xml
Executable file
25
tests/core/common/utils/fuzztest/updatedbpassword_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "updatedbpassword_fuzzer.h"
|
||||
#include "sqlite3_utils.h"
|
||||
#include <securec.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include "softbus_adapter_mem.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool UpdateDbPasswordFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DbContext *ctx = nullptr;
|
||||
UpdateDbPassword(ctx, data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::UpdateDbPasswordFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_UPDATEDBPASSWORD_FUZZER_H
|
||||
#define TEST_FUZZTEST_UPDATEDBPASSWORD_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "updatedbpassword_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_UPDATEDBPASSWORD_FUZZER_H */
|
@ -20,15 +20,23 @@ group("fuzztest") {
|
||||
"getallnodedeviceinfo_fuzzer:GetAllNodeDeviceInfoFuzzTest",
|
||||
"getlocalnodedeviceinfo_fuzzer:GetLocalNodeDeviceInfoFuzzTest",
|
||||
"getnodekeyinfo_fuzzer:GetNodeKeyInfoFuzzTest",
|
||||
"getnodekeyinfoinner_fuzzer:GetNodeKeyInfoInnerFuzzTest",
|
||||
"joinlnn_fuzzer:JoinLNNFuzzTest",
|
||||
"joinmetanode_fuzzer:JoinMetaNodeFuzzTest",
|
||||
"joinmetanodelnner_fuzzer:JoinMetaNodeInnerFuzzTest",
|
||||
"leavelnn_fuzzer:LeaveLNNFuzzTest",
|
||||
"leavelnninner_fuzzer:LeaveLNNInnerFuzzTest",
|
||||
"publishlnn_fuzzer:PublishLNNFuzzTest",
|
||||
"refreshlnn_fuzzer:RefreshLNNFuzzTest",
|
||||
"regnodedevicestatecb_fuzzer:RegNodeDeviceStateCbFuzzTest",
|
||||
"setnodedatachangeflag_fuzzer:SetNodeDataChangeFlagFuzzTest",
|
||||
"shiftlnngear_fuzzer:ShiftLnnGearFuzzTest",
|
||||
"starttimesync_fuzzer:StartTimeSyncFuzzTest",
|
||||
"starttimesyncinner_fuzzer:StartTimeSyncInnerFuzzTest",
|
||||
"starttimesyncinner_fuzzer:StartTimeSyncInnerFuzzTest",
|
||||
"stoppublishlnn_fuzzer:StopPublishLNNFuzzTest",
|
||||
"stoprefreshlnn_fuzzer:StopRefreshLNNFuzzTest",
|
||||
"stoptimesync_fuzzer:StopTimeSyncFuzzTest",
|
||||
"stoptimesyncinner_fuzzer:StopTimeSyncInnerFuzzTest",
|
||||
]
|
||||
}
|
||||
|
47
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("GetNodeKeyInfoInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "getnodekeyinfoinner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "getnodekeyinfoinner_fuzzer.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include "softbus_errcode.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool GetNodeKeyInfoInnerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
NodeDeviceInfoKey key = NODE_KEY_NETWORK_CAPABILITY;
|
||||
uint8_t udid[UDID_BUF_LEN] = {0};
|
||||
GetNodeKeyInfoInner((const char *)data,
|
||||
const_cast<char *>(reinterpret_cast<const char *>(data)), key, udid, UDID_BUF_LEN);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::GetNodeKeyInfoInnerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_GETNODEKEYINFOINNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_GETNODEKEYINFOINNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getnodekeyinfoinner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_GETNODEKEYINFOINNER_FUZZER_H */
|
25
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/getnodekeyinfoinner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
47
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("JoinMetaNodeFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "joinmetanode_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
78
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/joinmetanode_fuzzer.cpp
Executable file
78
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/joinmetanode_fuzzer.cpp
Executable file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "joinmetanode_fuzzer.h"
|
||||
#include "client_bus_center.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_type_def.h"
|
||||
#include "softbus_bus_center.h"
|
||||
|
||||
namespace OHOS {
|
||||
void JoinMetaNodeCb(ConnectionAddr *addr, const char *networkId, int32_t retCode)
|
||||
{
|
||||
(void) addr;
|
||||
(void) networkId;
|
||||
(void) retCode;
|
||||
}
|
||||
|
||||
void LeaveMetaNodeCb(const char *networkId, int32_t retCode)
|
||||
{
|
||||
(void) networkId;
|
||||
(void) retCode;
|
||||
}
|
||||
|
||||
ConnectionAddr addr;
|
||||
static const int32_t MAX_CONNECT_TYPE = CONNECTION_ADDR_MAX;
|
||||
static const char *g_ip = "192.168.43.16";
|
||||
static const int32_t port = 6007;
|
||||
|
||||
void GenRandAddr(const uint8_t *data, size_t size)
|
||||
{
|
||||
addr.type = (ConnectionAddrType)(size % MAX_CONNECT_TYPE);
|
||||
memcpy_s(addr.peerUid, MAX_ACCOUNT_HASH_LEN, data, size);
|
||||
memcpy_s(addr.info.ip.ip, IP_STR_MAX_LEN, g_ip, strlen(g_ip));
|
||||
addr.info.ip.port = port + size;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
char pkgName[65] = {0};
|
||||
if (memcpy_s(pkgName, sizeof(pkgName) - 1, data, size) != EOK) {
|
||||
return true;
|
||||
}
|
||||
if (strnlen((const char *)pkgName, PKG_NAME_SIZE_MAX) >= PKG_NAME_SIZE_MAX) {
|
||||
return true;
|
||||
}
|
||||
GenRandAddr(data, size);
|
||||
JoinMetaNode((const char *)pkgName, &addr, (CustomData *)data, JoinMetaNodeCb);
|
||||
LeaveMetaNode(pkgName, (const char*)data, LeaveMetaNodeCb);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
20
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/joinmetanode_fuzzer.h
Executable file
20
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/joinmetanode_fuzzer.h
Executable file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_JOINMETANODE_FUZZER_H
|
||||
#define TEST_FUZZTEST_JOINMETANODE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "joinmetanode_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_JOINMETANODE_FUZZER_H */
|
25
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/joinmetanode_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
47
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("JoinMetaNodeInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "joinmetanodelnner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "joinmetanodelnner_fuzzer.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_def.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
void JoinMetaNodeCb(ConnectionAddr *addr, const char *networkId, int32_t retCode)
|
||||
{
|
||||
(void) addr;
|
||||
(void) networkId;
|
||||
(void) retCode;
|
||||
}
|
||||
|
||||
void LeaveMetaNodeCb(const char *networkId, int32_t retCode)
|
||||
{
|
||||
(void) networkId;
|
||||
(void) retCode;
|
||||
}
|
||||
|
||||
ConnectionAddr addr;
|
||||
static const int32_t MAX_CONNECT_TYPE = CONNECTION_ADDR_MAX;
|
||||
static const char *g_ip = "192.168.43.16";
|
||||
static const int32_t port = 6007;
|
||||
|
||||
void GenRandAddr(const uint8_t *data, size_t size)
|
||||
{
|
||||
addr.type = (ConnectionAddrType)(size % MAX_CONNECT_TYPE);
|
||||
memcpy_s(addr.peerUid, MAX_ACCOUNT_HASH_LEN, data, size);
|
||||
memcpy_s(addr.info.ip.ip, IP_STR_MAX_LEN, g_ip, strlen(g_ip));
|
||||
addr.info.ip.port = port + size;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
char pkgName[65] = {0};
|
||||
if (memcpy_s(pkgName, sizeof(pkgName) - 1, data, size) != EOK) {
|
||||
return true;
|
||||
}
|
||||
if (strnlen((const char *)pkgName, PKG_NAME_SIZE_MAX) >= PKG_NAME_SIZE_MAX) {
|
||||
return true;
|
||||
}
|
||||
GenRandAddr(data, size);
|
||||
JoinMetaNodeInner((const char *)pkgName, &addr, (CustomData *)data, JoinMetaNodeCb);
|
||||
LeaveMetaNodeInner(pkgName, (const char*)data, LeaveMetaNodeCb);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_JOINMETANODELNNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_JOINMETANODELNNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "joinmetanodelnner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_JOINMETANODELNNER_FUZZER_H */
|
25
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/joinmetanodelnner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
47
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("LeaveLNNInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "leavelnninner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
53
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/leavelnninner_fuzzer.cpp
Executable file
53
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/leavelnninner_fuzzer.cpp
Executable file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "leavelnninner_fuzzer.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include "softbus_errcode.h"
|
||||
|
||||
namespace OHOS {
|
||||
static void OnLeaveLNNResult(const char *networkId, int32_t retCode)
|
||||
{
|
||||
(void)networkId;
|
||||
(void)retCode;
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char tmp[65] = {0};
|
||||
if (memcpy_s(tmp, sizeof(tmp) - 1, data, size) != EOK) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LeaveLNNInner(reinterpret_cast<const char *>(tmp), reinterpret_cast<const char *>(data), OnLeaveLNNResult);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
21
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/leavelnninner_fuzzer.h
Executable file
21
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/leavelnninner_fuzzer.h
Executable file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_LEAVELNNINNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_LEAVELNNINNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "leavelnninner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_LEAVELNNINNER_FUZZER_H */
|
25
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/leavelnninner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
47
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SetNodeDataChangeFlagFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "setnodedatachangeflag_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/setnodedatachangeflag_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "setnodedatachangeflag_fuzzer.h"
|
||||
#include "client_bus_center.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_type_def.h"
|
||||
#include "softbus_bus_center.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
char *tmp = nullptr;
|
||||
uint16_t DATA_CHANGE_FLAG = 65535;
|
||||
SetNodeDataChangeFlag(tmp, (const char *)data, DATA_CHANGE_FLAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_SETNODEDATACHANGEFLAG_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETNODEDATACHANGEFLAG_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setnodedatachangeflag_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_SETNODEDATACHANGEFLAG_FUZZER_H */
|
47
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SetNodeDataChangeFlagInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "setnodedatachangeflaginner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/setnodedatachangeflaginner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "setnodedatachangeflaginner_fuzzer.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
char *tmp = nullptr;
|
||||
uint16_t DATA_CHANGE_FLAG = 65535;
|
||||
SetNodeDataChangeFlagInner(tmp, (const char *)data, DATA_CHANGE_FLAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef TEST_FUZZTEST_SETNODEDATACHANGEFLAGINNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_SETNODEDATACHANGEFLAGINNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setnodedatachangeflaginner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_SETNODEDATACHANGEFLAGINNER_FUZZER_H */
|
47
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("StartTimeSyncInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "starttimesyncinner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/starttimesyncinner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "starttimesyncinner_fuzzer.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
static void OnTimeSyncInnerResult(const TimeSyncResultInfo *info, int32_t retCode)
|
||||
{
|
||||
(void)info;
|
||||
(void)retCode;
|
||||
}
|
||||
|
||||
static ITimeSyncCb g_timeSyncCb = {
|
||||
.onTimeSyncResult = OnTimeSyncInnerResult,
|
||||
};
|
||||
|
||||
bool StartTimeSyncTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TimeSyncAccuracy timeAccuracy = SUPER_HIGH_ACCURACY;
|
||||
TimeSyncPeriod period = NORMAL_PERIOD;
|
||||
|
||||
StartTimeSyncInner((const char *)data, (const char *)data, timeAccuracy, period, &g_timeSyncCb);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::StartTimeSyncTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_STARTTIMESYNCINNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_STARTTIMESYNCINNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "starttimesyncinner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_STARTTIMESYNCINNER_FUZZER_H */
|
47
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/BUILD.gn
Executable file
47
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/BUILD.gn
Executable file
@ -0,0 +1,47 @@
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/test.gni")
|
||||
import("//foundation/communication/dsoftbus/dsoftbus.gni")
|
||||
module_output_path = "dsoftbus/bus_center"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("StopTimeSyncInnerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/communication/dsoftbus/tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer"
|
||||
include_dirs = [
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/interfaces/kits/bus_center",
|
||||
"$dsoftbus_root_path/interfaces/kits/common",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"$dsoftbus_root_path/adapter/common/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/service/include",
|
||||
"$dsoftbus_root_path/sdk/bus_center/manager/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fstack-protector-strong",
|
||||
]
|
||||
sources = [ "stoptimesyncinner_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "$dsoftbus_root_path/sdk:softbus_client" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
15
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/corpus/init
Executable file
15
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/corpus/init
Executable file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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
|
25
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/project.xml
Executable file
25
tests/sdk/bus_center/fuzztest/stoptimesyncinner_fuzzer/project.xml
Executable file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>64</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "stoptimesyncinner_fuzzer.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <securec.h>
|
||||
#include "softbus_bus_center.h"
|
||||
|
||||
namespace OHOS {
|
||||
bool StopTimeSyncTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
StopTimeSyncInner(reinterpret_cast<const char *>(data), reinterpret_cast<const char *>(data));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::StopTimeSyncTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_STOPTIMESYNCINNER_FUZZER_H
|
||||
#define TEST_FUZZTEST_STOPTIMESYNCINNER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "stoptimesyncinner_fuzzer"
|
||||
|
||||
#endif /* TEST_FUZZTEST_STOPTIMESYNCINNER_FUZZER_H */
|
Loading…
x
Reference in New Issue
Block a user