diff --git a/kernel.mk b/kernel.mk index a4bfb820cf806499820f20db6b26973c707f5851..585e1e93c73a471a44c71f424ac3373215b6af7f 100755 --- a/kernel.mk +++ b/kernel.mk @@ -63,7 +63,7 @@ endif ifneq ($(findstring $(BUILD_TYPE), small standard),) DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch -PRODUCT_PATCH_FILE := $(OHOS_BUILD_HOME)/vendor/hisilicon/watchos/patchs/$(DEVICE_NAME).patch +PRODUCT_PATCH_FILE := $(OHOS_BUILD_HOME)/vendor/hisilicon/watchos/patches/$(DEVICE_NAME).patch HDF_PATCH_FILE := $(DEVICE_PATCH_DIR)/hdf.patch SMALL_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME)_$(BUILD_TYPE).patch KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/$(KERNEL_IMAGE) diff --git a/test/fuzztest/accesstokenid/BUILD.gn b/test/fuzztest/accesstokenid/BUILD.gn index a637feb54660c7322d939c0afbed7500ed8be72e..b785496d9e38cb50b4904cc33c0a60c5eaca8ef1 100644 --- a/test/fuzztest/accesstokenid/BUILD.gn +++ b/test/fuzztest/accesstokenid/BUILD.gn @@ -1,38 +1,38 @@ -# 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. - -group("fuzztest") { - testonly = true - deps = [] - - deps += [ - "accessftokenidgrptest_fuzzer:AccessfTokenidGrpTestFuzzTest", - "accessftokenidgrptestother_fuzzer:AccessfTokenidGrpTestOtherFuzzTest", - "accessftokenidthreadtest_fuzzer:AccessfTokenidThreadTestFuzzTest", - "accesstokenidgrptest_fuzzer:AccessTokenidGrpTestFuzzTest", - "accesstokenidgrptestother_fuzzer:AccessTokenidGrpTestOtherFuzzTest", - "accesstokenidthreadtest_fuzzer:AccessTokenidThreadTestFuzzTest", - "getftokenidcmdcorrect_fuzzer:GetfTokenidCmdCorrectFuzzTest", - "getftokenidcmderror_fuzzer:GetfTokenidCmdErrorFuzzTest", - "getftokenidnullptr_fuzzer:GetfTokenidNullptrFuzzTest", - "gettokenidcmdcorrect_fuzzer:GetTokenidCmdCorrectFuzzTest", - "gettokenidcmderror_fuzzer:GetTokenidCmdErrorFuzzTest", - "gettokenidnullptr_fuzzer:GetTokenidNullptrFuzzTest", - "setftokenidcmdcorrect_fuzzer:SetfTokenidCmdCorrectFuzzTest", - "setftokenidcmderror_fuzzer:SetfTokenidCmdErrorFuzzTest", - "setftokenidnullptr_fuzzer:SetfTokenidNullptrFuzzTest", - "settokenidcmdcorrect_fuzzer:SetTokenidCmdCorrectFuzzTest", - "settokenidcmderror_fuzzer:SetTokenidCmdErrorFuzzTest", - "settokenidnullptr_fuzzer:SetTokenidNullptrFuzzTest", - ] -} +# 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. + +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + "accessftokenidgrptest_fuzzer:AccessfTokenidGrpTestFuzzTest", + "accessftokenidgrptestother_fuzzer:AccessfTokenidGrpTestOtherFuzzTest", + "accessftokenidthreadtest_fuzzer:AccessfTokenidThreadTestFuzzTest", + "accesstokenidgrptest_fuzzer:AccessTokenidGrpTestFuzzTest", + "accesstokenidgrptestother_fuzzer:AccessTokenidGrpTestOtherFuzzTest", + "accesstokenidthreadtest_fuzzer:AccessTokenidThreadTestFuzzTest", + "getftokenidcmdcorrect_fuzzer:GetfTokenidCmdCorrectFuzzTest", + "getftokenidcmderror_fuzzer:GetfTokenidCmdErrorFuzzTest", + "getftokenidnullptr_fuzzer:GetfTokenidNullptrFuzzTest", + "gettokenidcmdcorrect_fuzzer:GetTokenidCmdCorrectFuzzTest", + "gettokenidcmderror_fuzzer:GetTokenidCmdErrorFuzzTest", + "gettokenidnullptr_fuzzer:GetTokenidNullptrFuzzTest", + "setftokenidcmdcorrect_fuzzer:SetfTokenidCmdCorrectFuzzTest", + "setftokenidcmderror_fuzzer:SetfTokenidCmdErrorFuzzTest", + "setftokenidnullptr_fuzzer:SetfTokenidNullptrFuzzTest", + "settokenidcmdcorrect_fuzzer:SetTokenidCmdCorrectFuzzTest", + "settokenidcmderror_fuzzer:SetTokenidCmdErrorFuzzTest", + "settokenidnullptr_fuzzer:SetTokenidNullptrFuzzTest", + ] +} diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn index 25f6b34d81c1927d31763313f2c85b67c23ff139..98dd3ac59f11821f28af65329525a71cc1ab35c4 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessfTokenidGrpTestFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "accessftokenidgrptest_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessfTokenidGrpTestFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessfTokenidGrpTestFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "accessftokenidgrptest_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessfTokenidGrpTestFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp index c535b276f673a73131c438ea23a555b3ad9c7101..f8e37035b2554eb198fe641329e94a30b0bc7b03 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessfTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidGrpTest(data_ftoken); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessfTokenidGrpTestFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessfTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_ftoken = const_cast(data); + ret = AccessfTokenidGrpTest(data_ftoken); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessfTokenidGrpTestFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/project.xml b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn index d902d27f417973e42fb0de63fcbba0f6935de5db..1505955aef5fd5edd4b3c4926a93f263807f89db 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessfTokenidGrpTestOtherFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "accessftokenidgrptestother_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessfTokenidGrpTestOtherFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessfTokenidGrpTestOtherFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "accessftokenidgrptestother_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessfTokenidGrpTestOtherFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp index 399d77f49cbe2bf363a29dcd0d263dca7a206537..64b3776911d9a95955e4a6b453c0a12e6e2c424f 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessfTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidGrpTestOther(data_ftoken); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessfTokenidGrpTestOtherFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessfTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_ftoken = const_cast(data); + ret = AccessfTokenidGrpTestOther(data_ftoken); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessfTokenidGrpTestOtherFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/project.xml b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn index 3bdbd2bbb40092340d484da3c7d6a22b3fc20c11..a67bbd14ed77109553e92863c97d9484c9d5c6c6 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessfTokenidThreadTestFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "accessftokenidthreadtest_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessfTokenidThreadTestFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessfTokenidThreadTestFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "accessftokenidthreadtest_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessfTokenidThreadTestFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp index 42129808f82758415c5ffa9c8ea2598935b30ae3..7379f805942c2383b69ba97fbd0ad29df640056f 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessfTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidThreadTest(data_ftoken); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessfTokenidThreadTestFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessfTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_ftoken = const_cast(data); + ret = AccessfTokenidThreadTest(data_ftoken); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessfTokenidThreadTestFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/project.xml b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/BUILD.gn index c83fa86a5714f101f41e5d274c2723a8f6430592..a9b2c9d4b356a00bb46a79f4dd62e069f4bd551c 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessTokenidGrpTestFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "accesstokenidgrptest_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessTokenidGrpTestFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessTokenidGrpTestFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "accesstokenidgrptest_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessTokenidGrpTestFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp index af5b63685345d7d0c4710b08fef1619c9126aa1c..58e850eaaa7cb8f5b8dd80f7eb4bf83c261da7b5 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidGrpTest(data_token); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessTokenidGrpTestFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_token = const_cast(data); + ret = AccessTokenidGrpTest(data_token); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessTokenidGrpTestFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/project.xml b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/BUILD.gn index a7ffa34d55318a36c3a22d83f1843a6adc381059..76a78eb54181857115739a03ffce39ceba2dfecb 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessTokenidGrpTestOtherFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "accesstokenidgrptestother_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessTokenidGrpTestOtherFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessTokenidGrpTestOtherFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "accesstokenidgrptestother_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessTokenidGrpTestOtherFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp index a4e57da17d3d51a68e837588583f6a8787f7a158..8d47e228a1c7e3c0757f2977595f1940f3cace7a 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidGrpTestOther(data_token); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessTokenidGrpTestOtherFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_token = const_cast(data); + ret = AccessTokenidGrpTestOther(data_token); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessTokenidGrpTestOtherFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/project.xml b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/BUILD.gn index b643bcff5bbeb32309fe4657dd27eb5eefcebdd3..82cb4414a59f50031aa95313fa2f42a586c7f70d 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/BUILD.gn @@ -1,43 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("AccessTokenidThreadTestFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - "-pthread", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "accesstokenidthreadtest_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":AccessTokenidThreadTestFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("AccessTokenidThreadTestFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "accesstokenidthreadtest_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AccessTokenidThreadTestFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp index 5215747069b19cdb0e76324df45db7f2572a293e..e577102d3c11ea51126457f529599efafb0240ca 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool AccessTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidThreadTest(data_token); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::AccessTokenidThreadTestFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool AccessTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + uint8_t *data_token = const_cast(data); + ret = AccessTokenidThreadTest(data_token); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AccessTokenidThreadTestFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/corpus/init b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/project.xml b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn index dd833e2068a3286420d1f26f7a8c8193b5325c0f..f724d2e143418cd081383649d263612d280b8735 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetfTokenidCmdCorrectFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "getftokenidcmdcorrect_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetfTokenidCmdCorrectFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetfTokenidCmdCorrectFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "getftokenidcmdcorrect_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetfTokenidCmdCorrectFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/corpus/init b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp index 1173bb9352a3a98c6b0d14b8ae7b24f1bcc6d030..f8cfc3f0a545408eace32bf30d4069eee899e941 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetfTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetfTokenidCmdCorrectFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetfTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetfTokenidCmdCorrectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h index 314fb9de7c525f6c9b9f505e443a65ef65167b32..78f7458fe53fb9b6fd4baba6f128481b6212e2f4 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h @@ -1,21 +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_GETFTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "getftokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H +/* + * 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_GETFTOKENIDCMDCORRECT_FUZZER_H +#define TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H + +#define FUZZ_PROJECT_NAME "getftokenidcmdcorrect_fuzzer" + +#endif // TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/project.xml b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/project.xml index 27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d..afd90798db45dd3853b00cf9c476ad4b245107e1 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - + + + + + + 1000 + + 300 + + 4096 + \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn index 66b1aab8178c3de7ab0ef03e7bc287ac00a9f719..ca32e7e54b2aa70fd3e3642f204e8a754fb14abf 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetfTokenidCmdErrorFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "getftokenidcmderror_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetfTokenidCmdErrorFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetfTokenidCmdErrorFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "getftokenidcmderror_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetfTokenidCmdErrorFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/corpus/init b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp index 0ffb6a996379b9cdb5d2c4dadd386f5e6ac5449d..07819ec5a3437fcff939707c8d3e5a66652007ae 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp @@ -1,40 +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. - */ - -#include -#define CMDERROR -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetfTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetfTokenidCmdCorrectFuzzTest(data, size); - return 0; -} +/* + * 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 +#define CMDERROR +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetfTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetfTokenidCmdCorrectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h index 60a480440c7588d392b2e644b5f8cd8c7e103dbd..52960379a550a75b55b68b11035fb765fdaef297 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h @@ -1,21 +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_GETFTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H - -#define FUZZ_PROJECT_NAME "getftokenidcmderror_fuzzer" - -#endif // TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H +/* + * 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_GETFTOKENIDCMDERROR_FUZZER_H +#define TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H + +#define FUZZ_PROJECT_NAME "getftokenidcmderror_fuzzer" + +#endif // TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/project.xml b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/project.xml index 27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d..afd90798db45dd3853b00cf9c476ad4b245107e1 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - + + + + + + 1000 + + 300 + + 4096 + \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn index a7aa7278a55657d3651f13da66e2c3ac16bae9a8..097ee13dce307640b65bd29dc8f6438662be1acd 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetfTokenidNullptrFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "getftokenidnullptr_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetfTokenidNullptrFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetfTokenidNullptrFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "getftokenidnullptr_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetfTokenidNullptrFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/corpus/init b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp index c098598c96f64f3811bc60a111979a9425b9ac6b..f6f2318c081a2413a89513567efb1d7d34a95a59 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if (data == nullptr) { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetfTokenid(&tokenId); - } else { - return ret; - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetfTokenidNullptrFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetfTokenid(&tokenId); + } else { + return ret; + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetfTokenidNullptrFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/project.xml b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/BUILD.gn index 1e8be2f58612f95347dedcdccd6db8728efa9334..624c94dc405301af0062977b7fb5fdf628be0417 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetTokenidCmdCorrectFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "gettokenidcmdcorrect_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetTokenidCmdCorrectFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetTokenidCmdCorrectFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "gettokenidcmdcorrect_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetTokenidCmdCorrectFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/corpus/init b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp index 40762c219ab01753b52fd948f3be228ac15151a3..3e0d4675af1f3c3b9184ea3de653872fe3791ea5 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetTokenidCmdCorrectFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetTokenidCmdCorrectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h index 2ac8751939bb9810ce3ba007307b1ea178bd29b4..309751776630e7bd674084a6b49c30f2680b909f 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h @@ -1,21 +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_GETTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "gettokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H +/* + * 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_GETTOKENIDCMDCORRECT_FUZZER_H +#define TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H + +#define FUZZ_PROJECT_NAME "gettokenidcmdcorrect_fuzzer" + +#endif // TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/project.xml b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/BUILD.gn index d72acf87f2d142b5f0198ec16a2cc1715a00b99a..3bcb82059c6c6c9ca7d50a792a6ad25e2fd12b6c 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetTokenidCmdErrorFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "gettokenidcmderror_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetTokenidCmdErrorFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetTokenidCmdErrorFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "gettokenidcmderror_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetTokenidCmdErrorFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/corpus/init b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp index 46d305e8b425f7fea67f3e039097e1eee3b68ace..4c6b13b1170379e70ae7dde7ddf305441b2db168 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp @@ -1,40 +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 -#define CMDERROR -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetTokenidCmdErrorFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#define CMDERROR +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetTokenidCmdErrorFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h index 05459560403be0fc8753911f1a381a7b49718a8e..91f5f7a2bd57c74e785229cc1da881a84b0cb3db 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h @@ -1,21 +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_GETTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H - -#define FUZZ_PROJECT_NAME "gettokenidcmderror_fuzzer" - -#endif // TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H +/* + * 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_GETTOKENIDCMDERROR_FUZZER_H +#define TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H + +#define FUZZ_PROJECT_NAME "gettokenidcmderror_fuzzer" + +#endif // TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/project.xml b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/BUILD.gn index 912b3bc126c31f0da32383ffca5d4431e69c985b..0eb33fe99010994cc62c82e968e948e1cbddebb1 100644 --- a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("GetTokenidNullptrFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "gettokenidnullptr_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":GetTokenidNullptrFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("GetTokenidNullptrFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "gettokenidnullptr_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":GetTokenidNullptrFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/corpus/init b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp index 5be434efe3e662e364592d7f6f59f41af052354d..ed105a8f276143fb930da4e80b7b5e05fe3a9681 100644 --- a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool GetTokenidNullptrFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if (data == nullptr) { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetTokenid(&tokenId); - } else { - return ret; - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::GetTokenidNullptrFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool GetTokenidNullptrFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetTokenid(&tokenId); + } else { + return ret; + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::GetTokenidNullptrFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/project.xml b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h index e0c3903814f6e5c8f8ac84ac8bca07d9c2629a5d..66461a8f97dcce8a811c7eccc717cb6ed78eb3d1 100644 --- a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h @@ -1,70 +1,72 @@ -/* - * 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 ACCESSFTOKENIDCOMMON_H -#define ACCESSFTOKENIDCOMMON_H - -#define FUZZ_PROJECT_NAME "accessftokenidcommon" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' - -#ifdef CMDERROR -constexpr unsigned int GET_FTOKEN_ID = 0; -constexpr unsigned int SET_FTOKEN_ID = 0; -#else -constexpr unsigned int GET_FTOKEN_ID = 3; -constexpr unsigned int SET_FTOKEN_ID = 4; -#endif - -#define ACCESS_TOKENID_GET_FTOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long) -#define ACCESS_TOKENID_SET_FTOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long) - -#define LIST_NUM_1 1 -#define LIST_NUM_2 2 -#define TEST_VALUE 123 -#define CHILDREN_NUM 3 -#define WAIT_FOR_SHELL_OP_TIME 1 -#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1)) - -#define ACCESS_TOKEN_UID 3020 -#define ACCESS_TOKEN_GRPID 3020 - -#define ACCESS_TOKEN_OTHER_UID 1234 -#define ACCESS_TOKEN_OTHER_GRPID 1234 - -#define INVAL_TOKEN 0xffffffffffffffff - -int GetfTokenid(unsigned long long *ftoken); -int SetfTokenid(unsigned long long *ftoken); - -void SetUidAndGrp(); -void SetUidAndGrpOther(); -void GetCurfToken(unsigned long long *ftoken); -void SetRandfTokenAndCheck(unsigned long long *data_ftoken); -void fTokenTest(unsigned long long *data_ftoken); -void ThreadTest(unsigned long long *data_ftoken); -int AccessfTokenidThreadTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken); -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS - -#endif // ACCESSTOKENIDCOMMON_H +/* + * 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 + +#ifndef ACCESSFTOKENIDCOMMON_H +#define ACCESSFTOKENIDCOMMON_H + +#define FUZZ_PROJECT_NAME "accessftokenidcommon" + +namespace OHOS { +namespace Kernel { +namespace AccessToken { +#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' + +#ifdef CMDERROR +constexpr unsigned int GET_FTOKEN_ID = 0; +constexpr unsigned int SET_FTOKEN_ID = 0; +#else +constexpr unsigned int GET_FTOKEN_ID = 3; +constexpr unsigned int SET_FTOKEN_ID = 4; +#endif + +#define ACCESS_TOKENID_GET_FTOKENID \ + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long) +#define ACCESS_TOKENID_SET_FTOKENID \ + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long) + +#define LIST_NUM_1 1 +#define LIST_NUM_2 2 +#define TEST_VALUE 123 +#define CHILDREN_NUM 3 +#define WAIT_FOR_SHELL_OP_TIME 1 +#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1)) + +#define ACCESS_TOKEN_UID 3020 +#define ACCESS_TOKEN_GRPID 3020 + +#define ACCESS_TOKEN_OTHER_UID 1234 +#define ACCESS_TOKEN_OTHER_GRPID 1234 + +#define INVAL_TOKEN 0xffffffffffffffff + +int GetfTokenid(unsigned long long *ftoken); +int SetfTokenid(unsigned long long *ftoken); + +void SetUidAndGrp(); +void SetUidAndGrpOther(); +void GetCurfToken(unsigned long long *ftoken); +void SetRandfTokenAndCheck(unsigned long long *data_ftoken); +void fTokenTest(unsigned long long *data_ftoken); +void ThreadTest(unsigned long long *data_ftoken); +int AccessfTokenidThreadTest(uint8_t *data_ftoken); +int AccessfTokenidGrpTest(uint8_t *data_ftoken); +int AccessfTokenidGrpTestOther(uint8_t *data_ftoken); +} // namespace AccessToken +} // namespace Kernel +} // namespace OHOS + +#endif // ACCESSTOKENIDCOMMON_H diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index febe47573e273447a4db1992012e962dc20b96d3..288919d258eea4efc16771c0a14e79d5d7650601 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -1,70 +1,72 @@ -/* - * 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 ACCESSTOKENIDCOMMON_H -#define ACCESSTOKENIDCOMMON_H - -#define FUZZ_PROJECT_NAME "accesstokenidcommon" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' - -#ifdef CMDERROR -constexpr unsigned int GET_TOKEN_ID = 0; -constexpr unsigned int SET_TOKEN_ID = 0; -#else -constexpr unsigned int GET_TOKEN_ID = 1; -constexpr unsigned int SET_TOKEN_ID = 2; -#endif - -#define ACCESS_TOKENID_GET_TOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) -#define ACCESS_TOKENID_SET_TOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) - -#define LIST_NUM_1 1 -#define LIST_NUM_2 2 -#define TEST_VALUE 123 -#define CHILDREN_NUM 3 -#define WAIT_FOR_SHELL_OP_TIME 1 -#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1)) - -#define ACCESS_TOKEN_UID 3020 -#define ACCESS_TOKEN_GRPID 3020 - -#define ACCESS_TOKEN_OTHER_UID 1234 -#define ACCESS_TOKEN_OTHER_GRPID 1234 - -#define INVAL_TOKEN 0xffffffffffffffff - -int GetTokenid(unsigned long long *token); -int SetTokenid(unsigned long long *token); - -void SetUidAndGrp(); -void SetUidAndGrpOther(); -void GetCurToken(unsigned long long *token); -void SetRandTokenAndCheck(unsigned long long *data_token); -void TokenTest(unsigned long long *data_token); -void ThreadTest(unsigned long long *data_token); -int AccessTokenidThreadTest(uint8_t *data_token); -int AccessTokenidGrpTest(uint8_t *data_token); -int AccessTokenidGrpTestOther(uint8_t *data_token); -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS - -#endif // ACCESSTOKENIDCOMMON_H +/* + * 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 + +#ifndef ACCESSTOKENIDCOMMON_H +#define ACCESSTOKENIDCOMMON_H + +#define FUZZ_PROJECT_NAME "accesstokenidcommon" + +namespace OHOS { +namespace Kernel { +namespace AccessToken { +#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' + +#ifdef CMDERROR +constexpr unsigned int GET_TOKEN_ID = 0; +constexpr unsigned int SET_TOKEN_ID = 0; +#else +constexpr unsigned int GET_TOKEN_ID = 1; +constexpr unsigned int SET_TOKEN_ID = 2; +#endif + +#define ACCESS_TOKENID_GET_TOKENID \ + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) +#define ACCESS_TOKENID_SET_TOKENID \ + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) + +#define LIST_NUM_1 1 +#define LIST_NUM_2 2 +#define TEST_VALUE 123 +#define CHILDREN_NUM 3 +#define WAIT_FOR_SHELL_OP_TIME 1 +#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1)) + +#define ACCESS_TOKEN_UID 3020 +#define ACCESS_TOKEN_GRPID 3020 + +#define ACCESS_TOKEN_OTHER_UID 1234 +#define ACCESS_TOKEN_OTHER_GRPID 1234 + +#define INVAL_TOKEN 0xffffffffffffffff + +int GetTokenid(unsigned long long *token); +int SetTokenid(unsigned long long *token); + +void SetUidAndGrp(); +void SetUidAndGrpOther(); +void GetCurToken(unsigned long long *token); +void SetRandTokenAndCheck(unsigned long long *data_token); +void TokenTest(unsigned long long *data_token); +void ThreadTest(unsigned long long *data_token); +int AccessTokenidThreadTest(uint8_t *data_token); +int AccessTokenidGrpTest(uint8_t *data_token); +int AccessTokenidGrpTestOther(uint8_t *data_token); +} // namespace AccessToken +} // namespace Kernel +} // namespace OHOS + +#endif // ACCESSTOKENIDCOMMON_H diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn index bdabf6fa9cc37a6801b48d146972d4d2d402a90e..feb9a68a6e62b613f0bf3ab9beb6fc556b878f2d 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetfTokenidCmdCorrectFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "setftokenidcmdcorrect_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetfTokenidCmdCorrectFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetfTokenidCmdCorrectFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "setftokenidcmdcorrect_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetfTokenidCmdCorrectFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/corpus/init b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/project.xml b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/project.xml index 27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d..afd90798db45dd3853b00cf9c476ad4b245107e1 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - + + + + + + 1000 + + 300 + + 4096 + \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp index 000316cb94c492fd14bd3f28d4ad6a4eec791df3..847631692dd30d1c336343314c4387c851fc8ab4 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp @@ -1,39 +1,42 @@ -/* - * 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 -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetfTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetfTokenidCmdCorrectFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetfTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetfTokenidCmdCorrectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h index 0b440c269cba3ffe7fb0d3670ded743e405aec24..9d6d66337e27fb79f8fda153b044dc036e495d6b 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h @@ -1,21 +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_SETFTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "setftokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H +/* + * 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_SETFTOKENIDCMDCORRECT_FUZZER_H +#define TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H + +#define FUZZ_PROJECT_NAME "setftokenidcmdcorrect_fuzzer" + +#endif // TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn index 00fb0ffc6e165a7435d002b6b42a249fbe6b2e60..e3b0a2c4542346d4d3625a9734600a9e1e9e37d7 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetfTokenidCmdErrorFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "setftokenidcmderror_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetfTokenidCmdErrorFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetfTokenidCmdErrorFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "setftokenidcmderror_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetfTokenidCmdErrorFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/corpus/init b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/project.xml b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/project.xml index 27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d..afd90798db45dd3853b00cf9c476ad4b245107e1 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - + + + + + + 1000 + + 300 + + 4096 + \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp index 9a2f08595bfa7f7e3631adc2caf37411d3e41e60..e3d1c406d66b5ec9492763dc3bae03552778d32f 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp @@ -1,40 +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 -#define CMDERROR -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetfTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetfTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetfTokenidCmdErrorFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include "__config" +#define CMDERROR +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetfTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetfTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetfTokenidCmdErrorFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h index 3ab67c53750f506e4f4dafd58cc3fca9d9f7a005..9150efebadb642d637b73ff261c7d3de3e1f1d73 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h @@ -1,21 +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_SETFTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H - -#define FUZZ_PROJECT_NAME "setftokenidcmderror_fuzzer" - -#endif // TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H +/* + * 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_SETFTOKENIDCMDERROR_FUZZER_H +#define TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H + +#define FUZZ_PROJECT_NAME "setftokenidcmderror_fuzzer" + +#endif // TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn index 0847e822561b035a429bf7825a397478c8662c93..f41a490b9a86cc69d438ab28add93296c880ffc2 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetfTokenidNullptrFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accessftokenidcommon.cpp", - "setftokenidnullptr_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetfTokenidNullptrFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetfTokenidNullptrFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accessftokenidcommon.cpp", + "setftokenidnullptr_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetfTokenidNullptrFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/corpus/init b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/project.xml b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp index f79706f091622994daa87c5cb3c927df2ae88a9c..c44243ea92d113c984e3695e3532c7ae5e05b2bc 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accessftokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if (data == nullptr) { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetfTokenid(&tokenId); - } else { - return ret; - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetfTokenidNullptrFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include "accessftokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetfTokenidNullptrFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetfTokenid(&tokenId); + } else { + return ret; + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetfTokenidNullptrFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/BUILD.gn index 0def8993e6dbb8ec81dd88b2fab223649facc454..7e99e51914db9b36efbf160ed994985af3d4e06a 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/BUILD.gn @@ -1,41 +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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetTokenidCmdCorrectFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ - "../src/accesstokenidcommon.cpp", - "settokenidcmdcorrect_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetTokenidCmdCorrectFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetTokenidCmdCorrectFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "../src/accesstokenidcommon.cpp", + "settokenidcmdcorrect_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetTokenidCmdCorrectFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/corpus/init b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/project.xml b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp index 7183f678a1f862899d99c7c5ac411217b6267fc1..b4a1ef950ee72032d17619427c7244a5e1806ddf 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetTokenidCmdCorrectFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetTokenidCmdCorrectFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h index 4cc82cad5a4a8084a7a1453e9e4c0d29cf8d29ab..ee1b12e10275b83ee9264e591cbf860fd6c67027 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h @@ -1,21 +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_SETTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "settokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H +/* + * 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_SETTOKENIDCMDCORRECT_FUZZER_H +#define TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H + +#define FUZZ_PROJECT_NAME "settokenidcmdcorrect_fuzzer" + +#endif // TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/BUILD.gn index 037811e6c3e406eada1d9cbc06b647dc490c0fcf..fb3327d8342fd5c75d43b1d011661438f1ef6404 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetTokenidCmdErrorFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "settokenidcmderror_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetTokenidCmdErrorFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetTokenidCmdErrorFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "settokenidcmderror_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetTokenidCmdErrorFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/corpus/init b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/project.xml b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp index 37851e069437b857a1c7dbf629b6adab8e8f5002..66cb3c870aef1efec22f77f3b705272510664845 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp @@ -1,40 +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. - */ - -#include -#define CMDERROR -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetTokenid(&tokenId); - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetTokenidCmdErrorFuzzTest(data, size); - return 0; -} +/* + * 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 +#define CMDERROR +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetTokenid(&tokenId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetTokenidCmdErrorFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h index 78627a818e0a8220da26d642ebe2fc4fde28daa5..d680e50b13f329229d7e082c63423ee6136360a7 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h @@ -1,21 +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_SETTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H - -#define FUZZ_PROJECT_NAME "settokenidcmderror_fuzzer" - -#endif // TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H +/* + * 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_SETTOKENIDCMDERROR_FUZZER_H +#define TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H + +#define FUZZ_PROJECT_NAME "settokenidcmderror_fuzzer" + +#endif // TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H diff --git a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/BUILD.gn index 3b78e95cd07fb79f8c5e3084f7ebcb60030eac67..ebab3ea33ce45c42c4e0ce1919a4bad9ee0adced 100644 --- a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/BUILD.gn @@ -1,42 +1,42 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/accesstokenid" - -ohos_fuzztest("SetTokenidNullptrFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer" - - include_dirs = [ "../include" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ - "../src/accesstokenidcommon.cpp", - "settokenidnullptr_fuzzer.cpp", - ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":SetTokenidNullptrFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/accesstokenid" + +ohos_fuzztest("SetTokenidNullptrFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer" + + include_dirs = [ "../include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ + "../src/accesstokenidcommon.cpp", + "settokenidnullptr_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetTokenidNullptrFuzzTest" ] +} diff --git a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/corpus/init b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/corpus/init index 58ee85e5da3dcf11bcb8e41f5bd5312014a16989..dd290c4c3ae7481ebe36b824f3d3700b50594912 100644 --- a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/corpus/init +++ b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/corpus/init @@ -1,14 +1,14 @@ -# Copyright (c) 2020-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. - +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + FUZZ \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/project.xml b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/project.xml +++ b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp index 715454c97a7f05d5db7c2afaf7e9c978afb70878..bb730a55838d953e75de809d683720f0ee18e2ec 100644 --- a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp @@ -1,41 +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. - reinterpret_cast - static_cast - */ - -#include -#include "accesstokenidcommon.h" - -using namespace std; -using namespace OHOS::Kernel::AccessToken; -namespace OHOS { -bool SetTokenidNullptrFuzzTest(const uint8_t *data, size_t size) -{ - bool ret = false; - if (data == nullptr) { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetTokenid(&tokenId); - } else { - return ret; - } - return ret; -} -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::SetTokenidNullptrFuzzTest(data, size); - return 0; -} +/* + * 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. + reinterpret_cast + static_cast + */ + +#include +#include +#include +#include "__config" +#include "accesstokenidcommon.h" + +using namespace std; +using namespace OHOS::Kernel::AccessToken; +namespace OHOS { +bool SetTokenidNullptrFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetTokenid(&tokenId); + } else { + return ret; + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetTokenidNullptrFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp index 6fa504faad6fa345b43a814d1989b6f63c258a94..ad6c9b638a619db876904a0b7aae6050f0acdca1 100644 --- a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp @@ -1,195 +1,193 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "accessftokenidcommon.h" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -const char *DEVACCESSTOKENID = "/dev/access_token_id"; - -int GetfTokenid(unsigned long long *ftoken) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - - int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken); - if (ret) { - close(fd); - return -1; - } - - close(fd); - return 0; -} - -int SetfTokenid(unsigned long long *ftoken) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - - int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken); - if (ret) { - close(fd); - return -1; - } - - close(fd); - return 0; -} - -void SetUidAndGrp() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_2; - gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \n", ret); - } - - return; -} - -void SetUidAndGrpOther() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_1; - gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_OTHER_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \r\n", ret); - } - - return; -} - -void SetRandfTokenAndCheck(unsigned long long *data_ftoken) -{ - pid_t pid = getpid(); - pid_t tid = syscall(__NR_gettid); - unsigned long long ftoken = INVAL_TOKEN; - unsigned long long ftokenSet = *data_ftoken; - - SetfTokenid(&ftokenSet); - GetfTokenid(&ftoken); - - if (ftoken != ftokenSet) { - printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } else { - printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } - - sleep(WAIT_FOR_SHELL_OP_TIME); - - GetfTokenid(&ftoken); - if (ftoken != ftokenSet) { - printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } else { - printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } - return; -} - -void *fTokenTest(void *data_ftoken) -{ - SetRandfTokenAndCheck(static_cast(data_ftoken)); - return nullptr; -} - -void ThreadTest(void *data_ftoken) -{ - pthread_t id_1; - pthread_t id_2; - pthread_t id_3; - int ret = 0; - - ret = pthread_create(&id_1, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_2, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_3, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - pthread_join(id_1, nullptr); - pthread_join(id_2, nullptr); - pthread_join(id_3, nullptr); - - return; -} - -int AccessfTokenidThreadTest(uint8_t *data_ftoken) -{ - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} - -int AccessfTokenidGrpTest(uint8_t *data_ftoken) -{ - SetUidAndGrp(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} - -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken) -{ - SetUidAndGrpOther(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS +/* + * 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 +#include "accessftokenidcommon.h" +#include +#include +#include +#include +#include +#include "bits/syscall.h" +#include "stdio.h" + +namespace OHOS { +namespace Kernel { +namespace AccessToken { +const char *DEVACCESSTOKENID = "/dev/access_token_id"; + +int GetfTokenid(unsigned long long *ftoken) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + + int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken); + if (ret) { + close(fd); + return -1; + } + + close(fd); + return 0; +} + +int SetfTokenid(unsigned long long *ftoken) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + + int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken); + if (ret) { + close(fd); + return -1; + } + + close(fd); + return 0; +} + +void SetUidAndGrp() +{ + int ret = 0; + size_t groupListSize = LIST_NUM_2; + gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE}; + + ret = setgroups(groupListSize, groupList); + if (ret != 0) { + return; + } + + ret = setuid(ACCESS_TOKEN_UID); + if (ret != 0) { + printf("SetUidAndGrp setuid error %d \n", ret); + } + + return; +} + +void SetUidAndGrpOther() +{ + int ret = 0; + size_t groupListSize = LIST_NUM_1; + gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID}; + + ret = setgroups(groupListSize, groupList); + if (ret != 0) { + return; + } + + ret = setuid(ACCESS_TOKEN_OTHER_UID); + if (ret != 0) { + printf("SetUidAndGrp setuid error %d \r\n", ret); + } + + return; +} + +void SetRandfTokenAndCheck(unsigned long long *data_ftoken) +{ + pid_t pid = getpid(); + pid_t tid = syscall(__NR_gettid); + unsigned long long ftoken = INVAL_TOKEN; + unsigned long long ftokenSet = *data_ftoken; + + SetfTokenid(&ftokenSet); + GetfTokenid(&ftoken); + + if (ftoken != ftokenSet) { + printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } else { + printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } + + sleep(WAIT_FOR_SHELL_OP_TIME); + + GetfTokenid(&ftoken); + if (ftoken != ftokenSet) { + printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } else { + printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } + return; +} + +void *fTokenTest(void *data_ftoken) +{ + SetRandfTokenAndCheck(static_cast(data_ftoken)); + return nullptr; +} + +void ThreadTest(void *data_ftoken) +{ + pthread_t id_1; + pthread_t id_2; + pthread_t id_3; + int ret = 0; + + ret = pthread_create(&id_1, nullptr, fTokenTest, data_ftoken); + if (ret != 0) { + return; + } + + ret = pthread_create(&id_2, nullptr, fTokenTest, data_ftoken); + if (ret != 0) { + return; + } + + ret = pthread_create(&id_3, nullptr, fTokenTest, data_ftoken); + if (ret != 0) { + return; + } + + pthread_join(id_1, nullptr); + pthread_join(id_2, nullptr); + pthread_join(id_3, nullptr); + + return; +} + +int AccessfTokenidThreadTest(uint8_t *data_ftoken) +{ + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} + +int AccessfTokenidGrpTest(uint8_t *data_ftoken) +{ + SetUidAndGrp(); + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} + +int AccessfTokenidGrpTestOther(uint8_t *data_ftoken) +{ + SetUidAndGrpOther(); + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} +} // namespace AccessToken +} // namespace Kernel +} // namespace OHOS diff --git a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp index 1be96bd699a01d96b74c69a88b62d2a35a13e323..b0018670f13dfc6b6e1254671e36a6fa9c5d8759 100644 --- a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp @@ -1,192 +1,190 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "accesstokenidcommon.h" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -const char *DEVACCESSTOKENID = "/dev/access_token_id"; - -int GetTokenid(unsigned long long *token) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token); - if (ret) { - close(fd); - return -1; - } - close(fd); - return 0; -} - -int SetTokenid(unsigned long long *token) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token); - if (ret) { - close(fd); - return -1; - } - close(fd); - return 0; -} - -void SetUidAndGrp() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_2; - gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \n", ret); - } - - return; -} - -void SetUidAndGrpOther() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_1; - gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_OTHER_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \n", ret); - } - - return; -} - -void SetRandTokenAndCheck(unsigned long long *data_token) -{ - pid_t pid = getpid(); - pid_t tid = syscall(__NR_gettid); - unsigned long long token = INVAL_TOKEN; - unsigned long long tokenSet = *data_token; - - SetTokenid(&tokenSet); - GetTokenid(&token); - - if (token != tokenSet) { - printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n", - pid, tid, token, tokenSet); - } else { - printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n", - pid, tid, token, tokenSet); - } - - sleep(WAIT_FOR_SHELL_OP_TIME); - - GetTokenid(&token); - if (token != tokenSet) { - printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n", - pid, tid, token, tokenSet); - } else { - printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n", - pid, tid, token, tokenSet); - } - return; -} - -void *TokenTest(void *data_token) -{ - SetRandTokenAndCheck(static_cast(data_token)); - - return nullptr; -} - -void ThreadTest(void *data_token) -{ - pthread_t id_1; - pthread_t id_2; - pthread_t id_3; - int ret = 0; - - ret = pthread_create(&id_1, nullptr, TokenTest, data_token); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_2, nullptr, TokenTest, data_token); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_3, nullptr, TokenTest, data_token); - if (ret != 0) { - return; - } - - pthread_join(id_1, nullptr); - pthread_join(id_2, nullptr); - pthread_join(id_3, nullptr); - - return; -} - -int AccessTokenidThreadTest(uint8_t *data_token) -{ - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); - return 0; -} - -int AccessTokenidGrpTest(uint8_t *data_token) -{ - SetUidAndGrp(); - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); - return 0; -} - -int AccessTokenidGrpTestOther(uint8_t *data_token) -{ - SetUidAndGrpOther(); - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); - return 0; -} -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS +/* + * 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 +#include "accesstokenidcommon.h" +#include +#include +#include +#include +#include +#include "bits/syscall.h" +#include "stdio.h" + +namespace OHOS { +namespace Kernel { +namespace AccessToken { +const char *DEVACCESSTOKENID = "/dev/access_token_id"; + +int GetTokenid(unsigned long long *token) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token); + if (ret) { + close(fd); + return -1; + } + close(fd); + return 0; +} + +int SetTokenid(unsigned long long *token) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token); + if (ret) { + close(fd); + return -1; + } + close(fd); + return 0; +} + +void SetUidAndGrp() +{ + int ret = 0; + size_t groupListSize = LIST_NUM_2; + gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE}; + + ret = setgroups(groupListSize, groupList); + if (ret != 0) { + return; + } + + ret = setuid(ACCESS_TOKEN_UID); + if (ret != 0) { + printf("SetUidAndGrp setuid error %d \n", ret); + } + + return; +} + +void SetUidAndGrpOther() +{ + int ret = 0; + size_t groupListSize = LIST_NUM_1; + gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID}; + + ret = setgroups(groupListSize, groupList); + if (ret != 0) { + return; + } + + ret = setuid(ACCESS_TOKEN_OTHER_UID); + if (ret != 0) { + printf("SetUidAndGrp setuid error %d \n", ret); + } + + return; +} + +void SetRandTokenAndCheck(unsigned long long *data_token) +{ + pid_t pid = getpid(); + pid_t tid = syscall(__NR_gettid); + unsigned long long token = INVAL_TOKEN; + unsigned long long tokenSet = *data_token; + + SetTokenid(&tokenSet); + GetTokenid(&token); + + if (token != tokenSet) { + printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n", + pid, tid, token, tokenSet); + } else { + printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n", + pid, tid, token, tokenSet); + } + + sleep(WAIT_FOR_SHELL_OP_TIME); + + GetTokenid(&token); + if (token != tokenSet) { + printf("pid:%d tid:%d token test failed, token:%llu tokenSet:%llu\n", + pid, tid, token, tokenSet); + } else { + printf("pid:%d tid:%d token test succeed, token:%llu tokenSet:%llu\n", + pid, tid, token, tokenSet); + } + return; +} + +void *TokenTest(void *data_token) +{ + SetRandTokenAndCheck(static_cast(data_token)); + + return nullptr; +} + +void ThreadTest(void *data_token) +{ + pthread_t id_1; + pthread_t id_2; + pthread_t id_3; + int ret = 0; + + ret = pthread_create(&id_1, nullptr, TokenTest, data_token); + if (ret != 0) { + return; + } + + ret = pthread_create(&id_2, nullptr, TokenTest, data_token); + if (ret != 0) { + return; + } + + ret = pthread_create(&id_3, nullptr, TokenTest, data_token); + if (ret != 0) { + return; + } + + pthread_join(id_1, nullptr); + pthread_join(id_2, nullptr); + pthread_join(id_3, nullptr); + + return; +} + +int AccessTokenidThreadTest(uint8_t *data_token) +{ + TokenTest(static_cast(data_token)); + ThreadTest(static_cast(data_token)); + return 0; +} + +int AccessTokenidGrpTest(uint8_t *data_token) +{ + SetUidAndGrp(); + TokenTest(static_cast(data_token)); + ThreadTest(static_cast(data_token)); + return 0; +} + +int AccessTokenidGrpTestOther(uint8_t *data_token) +{ + SetUidAndGrpOther(); + TokenTest(static_cast(data_token)); + ThreadTest(static_cast(data_token)); + return 0; +} +} // namespace AccessToken +} // namespace Kernel +} // namespace OHOS diff --git a/test/fuzztest/hc_node/BUILD.gn b/test/fuzztest/hc_node/BUILD.gn index 13df32a50487b541cf6f8e2fa2a54dff6d7fd4ce..7ae33be50c61a44c713c4d44d088384fbcb0f701 100644 --- a/test/fuzztest/hc_node/BUILD.gn +++ b/test/fuzztest/hc_node/BUILD.gn @@ -1,29 +1,29 @@ -# 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. - -group("fuzztest") { - testonly = true - deps = [] - - deps += [ - "hcenable_fuzzer:HcEnableFuzzTest", - "hchotdatalowerlimit_fuzzer:HcHotDataLowerLimitFuzzTest", - "hchotdatawaterline_fuzzer:HcHotDataWaterlineFuzzTest", - "hchotnodelowerlimit_fuzzer:HcHotNodeLowerLimitFuzzTest", - "hchotnodewaterline_fuzzer:HcHotNodeWaterLineFuzzTest", - "hcwarmdatalowerlimit_fuzzer:HcWarmDataLowerLimitFuzzTest", - "hcwarmdatawaterline_fuzzer:HcWarmDataWaterLineFuzzTest", - "hcwarmnodelowerlimit_fuzzer:HcWarmNodeLowerLimitFuzzTest", - "hcwarmnodewaterline_fuzzer:HcWarmNodeWaterLineFuzzTest", - ] -} +# 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. + +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + "hcenable_fuzzer:HcEnableFuzzTest", + "hchotdatalowerlimit_fuzzer:HcHotDataLowerLimitFuzzTest", + "hchotdatawaterline_fuzzer:HcHotDataWaterlineFuzzTest", + "hchotnodelowerlimit_fuzzer:HcHotNodeLowerLimitFuzzTest", + "hchotnodewaterline_fuzzer:HcHotNodeWaterLineFuzzTest", + "hcwarmdatalowerlimit_fuzzer:HcWarmDataLowerLimitFuzzTest", + "hcwarmdatawaterline_fuzzer:HcWarmDataWaterLineFuzzTest", + "hcwarmnodelowerlimit_fuzzer:HcWarmNodeLowerLimitFuzzTest", + "hcwarmnodewaterline_fuzzer:HcWarmNodeWaterLineFuzzTest", + ] +} diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn index d2edc284413c9fd5bee27e37d57a04202f6a0d57..a33a390019205214f71523ca6d6551d852980823 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn @@ -1,37 +1,37 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcEnableFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hcenable_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hcenable_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcEnableFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcEnableFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hcenable_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hcenable_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcEnableFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/corpus/init b/test/fuzztest/hc_node/hcenable_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hcenable_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp index 7c7c9f0e399662e5014e4c540f0c66d176e4e3f8..b9415f6894ee7f6de0a0fdd767fe3936a77590c0 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable"; - -namespace OHOS { -bool HcEnableFuzzer(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_ENABLE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_ENABLE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcEnableFuzzer(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable"; + +namespace OHOS { +bool HcEnableFuzzer(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_ENABLE, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_ENABLE); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcEnableFuzzer(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/project.xml b/test/fuzztest/hc_node/hcenable_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hcenable_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn index dc889e81f51aff9f36451443334aa72e454e8ff9..8cac8d3fbf6c0e9228bd89f55c06b8dca1891eac 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn @@ -1,37 +1,37 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcHotDataLowerLimitFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hchotdatalowerlimit_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcHotDataLowerLimitFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcHotDataLowerLimitFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hchotdatalowerlimit_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcHotDataLowerLimitFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/corpus/init b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp index 8a1af0c376f8c3c8237c2a1b0e168e8c297c9f3f..ef65789a3111ae19e078a0ee23bf1e06fe7bcfd1 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit"; - -namespace OHOS { -bool HcHotDataLowerLimitFuzzer(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_DATA_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_DATA_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcHotDataLowerLimitFuzzer(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit"; + +namespace OHOS { +bool HcHotDataLowerLimitFuzzer(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_HOT_DATA_LOWER_LIMIT, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_HOT_DATA_LOWER_LIMIT); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcHotDataLowerLimitFuzzer(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/project.xml b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn index ba64e31647d4f5dfd347a3455f279b825272a599..b8e06a61e8abe88161b53923b9e0cf1dba56b109 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn @@ -1,37 +1,37 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcHotDataWaterlineFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hchotdatawaterline_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hchotdatawaterline_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcHotDataWaterlineFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcHotDataWaterlineFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hchotdatawaterline_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hchotdatawaterline_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcHotDataWaterlineFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/corpus/init b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp index 189b67b6399f09f93c91fac02540dafc080c3d62..418435fb38794b48fa92332d040fc6d6b50c938a 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline"; - -namespace OHOS { -bool HcHotDataWaterlineFuzzer(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_DATA_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_DATA_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcHotDataWaterlineFuzzer(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline"; + +namespace OHOS { +bool HcHotDataWaterlineFuzzer(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_HOT_DATA_WATERLINE, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_HOT_DATA_WATERLINE); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcHotDataWaterlineFuzzer(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/project.xml b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn index 2ff4a14c5637fa87cfec535d7d3ec0145e778c05..2971a092e78ebd70dcadad2ffe11ab8b6d517890 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn @@ -1,37 +1,37 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcHotNodeLowerLimitFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hchotnodelowerlimit_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcHotNodeLowerLimitFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcHotNodeLowerLimitFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hchotnodelowerlimit_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcHotNodeLowerLimitFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/corpus/init b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp index 5799c61c7c09a236ebedc3b99d08dd78fba238f4..5e1a20f0c1ad28057282b96876e2b0e9cfaf7685 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit"; - -namespace OHOS { -bool HcHotNodeLowerLimitFuzzTest(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_NODE_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_NODE_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcHotNodeLowerLimitFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit"; + +namespace OHOS { +bool HcHotNodeLowerLimitFuzzTest(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_HOT_NODE_LOWER_LIMIT, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_HOT_NODE_LOWER_LIMIT); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcHotNodeLowerLimitFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/project.xml b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn index f31385874a9b6083cd6d91b7cb73d8e42bc23fc4..19880fc6ab5202af932efcfd9dacf77c976fdaa7 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn @@ -1,36 +1,36 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcHotNodeWaterLineFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hchotnodewaterline_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hchotnodewaterline_fuzzer.cpp" ] -} -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcHotNodeWaterLineFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcHotNodeWaterLineFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hchotnodewaterline_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hchotnodewaterline_fuzzer.cpp" ] +} +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcHotNodeWaterLineFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/corpus/init b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp index 2ef9b15343db670326512f975da9b1f78954e6b6..251c7001af88b8d875ed8f2074d3666607c5ddda 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline"; - -namespace OHOS { -bool HcHotNodeWaterlineFuzzTest(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_NODE_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_NODE_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcHotNodeWaterlineFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline"; + +namespace OHOS { +bool HcHotNodeWaterlineFuzzTest(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_HOT_NODE_WATERLINE, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_HOT_NODE_WATERLINE); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcHotNodeWaterlineFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/project.xml b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn index 2a1f7fe48ba897e73f7e0e3dcb4f6194dfcfbe26..714d9aa82e5b6e8a20820c00837b21109a78a0de 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn @@ -1,36 +1,36 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcWarmDataLowerLimitFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hcwarmdatalowerlimit_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcWarmDataLowerLimitFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcWarmDataLowerLimitFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hcwarmdatalowerlimit_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcWarmDataLowerLimitFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/corpus/init b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/corpus/init index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..1c6cd97a6d25dea7d7a5311f1eddd5c9c67116b5 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# 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. +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp index 9691fbaa026633f9d49adee860a7eb893d48f01a..bfb3e1992f3d3291b1c42d2efbf8ee4e5eb3a0b9 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit"; - -namespace OHOS { -bool HcWarmDataLowerLimitFuzzTest(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_DATA_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_DATA_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcWarmDataLowerLimitFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit"; + +namespace OHOS { +bool HcWarmDataLowerLimitFuzzTest(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_WARM_DATA_LOWER_LIMIT, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_WARM_DATA_LOWER_LIMIT); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcWarmDataLowerLimitFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/project.xml b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn index 76517cb8d525ffa8f858b0861c88113b57c81ad8..ee553a6121f77ba4ff84ffe7ed3b0e18ca5231af 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn @@ -1,36 +1,36 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcWarmDataWaterLineFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hcwarmdatawaterline_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcWarmDataWaterLineFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcWarmDataWaterLineFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hcwarmdatawaterline_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcWarmDataWaterLineFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/corpus/init b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/corpus/init index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..1c6cd97a6d25dea7d7a5311f1eddd5c9c67116b5 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# 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. +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp index 040152f8453c07c18f5e669a897f3b78ebbae7af..deb98d9cfc4ee103d14e85e283123b3cbc4f1166 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline"; - -namespace OHOS { -bool HcWarmDataWaterLineFuzzTest(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_DATA_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_DATA_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcWarmDataWaterLineFuzzTest(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline"; + +namespace OHOS { +bool HcWarmDataWaterLineFuzzTest(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_WARM_DATA_WATERLINE, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_WARM_DATA_WATERLINE); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcWarmDataWaterLineFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/project.xml b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn index 11d6cbfbd783b243255bb9ae63a7d87e812cd5b7..474abe49008d15c44517bd7877aa790c33d54459 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn @@ -1,37 +1,37 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") - -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcWarmNodeLowerLimitFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hcwarmnodelowerlimit_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcWarmNodeLowerLimitFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcWarmNodeLowerLimitFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hcwarmnodelowerlimit_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcWarmNodeLowerLimitFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/corpus/init b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp index e5d3b2315c9be5ea228f89adabe215a958d0c176..5df5588529f35fb1bde647796a1c457b2ea1434b 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp @@ -1,65 +1,64 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit"; - -namespace OHOS { -bool HcWarmNodeLowerLimit(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_NODE_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_NODE_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcWarmNodeLowerLimit(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include "stdio.h" +#include "stdlib.h" + +const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit"; + +namespace OHOS { +bool HcWarmNodeLowerLimit(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_WARM_NODE_LOWER_LIMIT, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_WARM_NODE_LOWER_LIMIT); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcWarmNodeLowerLimit(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/project.xml b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn index 82873d4ac586384a52178f6522838403b9d7f09b..28231fa62f7a50aa5de104db0b448c5aa5fd1933 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn @@ -1,36 +1,36 @@ -# 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. - -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "linuxkerneltest/hc_node" - -ohos_fuzztest("HcWarmNodeWaterLineFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "hcwarmnodewaterline_fuzzer.cpp" ] -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":HcWarmNodeWaterLineFuzzTest" ] -} +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "linuxkerneltest/hc_node" + +ohos_fuzztest("HcWarmNodeWaterLineFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "hcwarmnodewaterline_fuzzer.cpp" ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":HcWarmNodeWaterLineFuzzTest" ] +} diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/corpus/init b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/corpus/init index 6703f24fa867db64080597bc962d22e0cc927766..76f18bd7a7e23e300a5708e8f968f8e8fc0d0c8c 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/corpus/init +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/corpus/init @@ -1,13 +1,13 @@ -# Copyright (c) 2020-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. +# Copyright (c) 2020-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FUZZ \ No newline at end of file diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp index 4c19bc2767b246c728eed4361a19c7839d3690d0..46233d955c7237b14defea262faa12fdb8e79d0e 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp @@ -1,65 +1,65 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -const char *HC_WARM_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_node_waterline"; - -namespace OHOS { -bool HcWarmNodeLowerWaterLine(const uint8_t *data, size_t size) -{ - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_NODE_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_NODE_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; -} -} // namespace OHOS - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - OHOS::HcWarmNodeLowerWaterLine(data, size); - return 0; -} +/* + * 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 +#include +#include +#include +#include +#include +#include + +const char *HC_WARM_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_node_waterline"; + +namespace OHOS { +bool HcWarmNodeLowerWaterLine(const uint8_t *data, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } + + int fd = open(HC_WARM_NODE_WATERLINE, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + printf("%s read fail\n", HC_WARM_NODE_WATERLINE); + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} // namespace OHOS + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::HcWarmNodeLowerWaterLine(data, size); + return 0; +} diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/project.xml b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/project.xml index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..1020c7b430f25037af4c1531f98400dad761bd28 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/project.xml +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/project.xml @@ -1,25 +1,25 @@ - - - - - - 1000 - - 300 - - 4096 - - + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh index f327f9a7609efdd2f4f135e58ac7ffc590b6dbf3..29c953b684e18b2c06f6856a2642caeb7fc68b70 100644 --- a/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh +++ b/test/moduletest/runtest/bin/cpuisolation_t/testcases/bin/cpuisolation03.sh @@ -224,7 +224,7 @@ active_cpu_online() isolated_num3=$(( $isolated_num3 + 1 )) done if [ $isolated_num3 -eq 2 ]; then - tst_res TPASS "isolated number doesnt change." + tst_res TPASS "isolated number does not change." else tst_res TFAIL "isolated number had been changed." fi @@ -243,4 +243,4 @@ do_clean() do_setup do_test do_clean -tst_exit \ No newline at end of file +tst_exit diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh index 267a0c88239a71ab52f0190047fb8ef77051918d..429b78b32baac56a41bf0622ab58bf65f5ea1afd 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh @@ -65,7 +65,7 @@ do_test() fi local rtgid3=$(cat $sched_group_id) if [ $rtgid3 -eq 3 ]; then - tst_res TFAIL "process $PID switch rtgid 2 to 3 sucess unexpected!" + tst_res TFAIL "process $PID switch rtgid 2 to 3 success unexpected!" res=$(($res + 1)) fi @@ -96,4 +96,4 @@ do_clean() do_setup do_test do_clean -tst_exit \ No newline at end of file +tst_exit diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh index 50668323779b172c5b49397577c0a608b80d1375..e69d87130c377ada2227e0f5ac33e8641d83ca83 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh @@ -65,7 +65,7 @@ stability_test() tst_res TINFO "kill 40 task processes...." ps -ef | grep "create_process" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 sleep 5 - tst_res TINFO "kill process successed." + tst_res TINFO "kill process succeeded." aa start -b ohos.samples.ecg -a ohos.samples.ecg.default && sleep 1 && PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') @@ -147,4 +147,4 @@ do_clean() do_setup do_test do_clean -tst_exit \ No newline at end of file +tst_exit diff --git a/test/unittest/accesstokenid/accesstokenid_test.cpp b/test/unittest/accesstokenid/accesstokenid_test.cpp index ae75dec5f3e28532b4ad80be56dc3b0573c7f527..abdfd4731b547816ea7f027005595b6268d4ab13 100644 --- a/test/unittest/accesstokenid/accesstokenid_test.cpp +++ b/test/unittest/accesstokenid/accesstokenid_test.cpp @@ -321,7 +321,7 @@ HWTEST_F(AccesstokenidTest, CheckChildThreadInheritance, Function | MediumTest | /** * @tc.name: CheckChildThreadSetIndepent - * @tc.desc: Test each child thread tokenid and ftokenid is indepent + * @tc.desc: Test each child thread tokenid and ftokenid is independent * @tc.desc: The tokenid and ftokenid of each child thread not equal to father process * @tc.type: FUNC */