From 55f676066efc038ec7d12530094728d4809edd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 10:57:17 +0000 Subject: [PATCH 01/15] =?UTF-8?q?Signed-off-by:=20=E4=B9=BE=E9=98=B3?= =?UTF-8?q?=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addparamentry_fuzzer.cpp | 68 +++++++++++++++++++ .../addparamentry_fuzzer.h | 20 ++++++ .../fuzztest/addparamentry_fuzzer/corpus/init | 16 +++++ .../fuzztest/addparamentry_fuzzer/project.xml | 25 +++++++ 4 files changed, 129 insertions(+) create mode 100644 test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp create mode 100644 test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.h create mode 100644 test/fuzztest/addparamentry_fuzzer/corpus/init create mode 100644 test/fuzztest/addparamentry_fuzzer/project.xml diff --git a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp new file mode 100644 index 000000000..b139e9cfe --- /dev/null +++ b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "addparamentry_fuzzer.h" +#include +#include +#include "param_trie.h" +#include "param_manager.h" +#include "securec.h" + + +namespace OHOS { + bool FuzzAddParamEntry(const uint8_t* data, size_t size) + { + if (size < 2) { + return false; + } + + size_t split_pos = size / 2; + if (split_pos == 0) { + split_pos = 1; + } + + std::unique_ptr name(new char[split_pos + 1]); + if (memcpy_s(name.get(), split_pos + 1, data, split_pos) != 0) { + return false; + } + name[split_pos] = '\0'; + + size_t value_size = size - split_pos; + std::unique_ptr value(new char[value_size + 1]); + if (memcpy_s(value.get(), value_size + 1, data + split_pos, value_size) != 0) { + return false; + } + value[value_size] = '\0'; + + uint32_t index = 0; + if (memcpy_s(&index, sizeof(uint32_t), data, sizeof(uint32_t)) != 0) { + index = 0; + } + index %= 1000; + + uint8_t type = 0; + if (size > 0) { + type = data[0] % 5; + } + + return (AddParamEntry(index, type, name.get(), value.get()) == 0); + } +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::FuzzAddParamEntry(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.h b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.h new file mode 100644 index 000000000..72d69b470 --- /dev/null +++ b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_ADD_PARAM_ENTRY_H +#define TEST_FUZZTEST_ADD_PARAM_ENTRY_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "addparamentry_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/addparamentry_fuzzer/corpus/init b/test/fuzztest/addparamentry_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/addparamentry_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/addparamentry_fuzzer/project.xml b/test/fuzztest/addparamentry_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/addparamentry_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + -- Gitee From baeff63aeed8db8f079c7b87e2c04ee2338ba064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 10:58:40 +0000 Subject: [PATCH 02/15] =?UTF-8?q?Signed-off-by:=20=E4=B9=BE=E9=98=B3?= =?UTF-8?q?=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addparamsecuritynode_fuzzer.cpp | 51 +++++++++++++++++ .../addparamsecuritynode_fuzzer.h | 20 +++++++ .../addparamsecuritynode_fuzzer/corpus/init | 16 ++++++ .../addparamsecuritynode_fuzzer/project.xml | 25 ++++++++ .../addsecuritylabel_fuzzer.cpp | 57 +++++++++++++++++++ .../addsecuritylabel_fuzzer.h | 20 +++++++ .../addsecuritylabel_fuzzer/corpus/init | 16 ++++++ .../addsecuritylabel_fuzzer/project.xml | 25 ++++++++ .../checkappwatchpermission_fuzzer.cpp | 43 ++++++++++++++ .../checkappwatchpermission_fuzzer.h | 20 +++++++ .../corpus/init | 16 ++++++ .../project.xml | 25 ++++++++ .../fuzztest/initworkspace_fuzzer/corpus/init | 16 ++++++ .../initworkspace_fuzzer.cpp | 53 +++++++++++++++++ .../initworkspace_fuzzer.h | 20 +++++++ .../fuzztest/initworkspace_fuzzer/project.xml | 25 ++++++++ 16 files changed, 448 insertions(+) create mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp create mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h create mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/corpus/init create mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/project.xml create mode 100644 test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp create mode 100644 test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h create mode 100644 test/fuzztest/addsecuritylabel_fuzzer/corpus/init create mode 100644 test/fuzztest/addsecuritylabel_fuzzer/project.xml create mode 100644 test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.cpp create mode 100644 test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.h create mode 100644 test/fuzztest/checkappwatchpermission_fuzzer/corpus/init create mode 100644 test/fuzztest/checkappwatchpermission_fuzzer/project.xml create mode 100644 test/fuzztest/initworkspace_fuzzer/corpus/init create mode 100644 test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp create mode 100644 test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.h create mode 100644 test/fuzztest/initworkspace_fuzzer/project.xml diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp new file mode 100644 index 000000000..2e886fe8e --- /dev/null +++ b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "addparamsecuritynode_fuzzer.h" +#include +#include +#include "param_trie.h" +#include "param_manager.h" + + +namespace OHOS { + bool FuzzAddParamSecurityNode(const uint8_t* data, size_t size) + { + if (size < sizeof(ParamAuditData)) { + return false; + } + + WorkSpace *workSpace = GetWorkSpace(0); + + const ParamAuditData* auditData = reinterpret_cast(data); + size_t remainingSize = size - sizeof(ParamAuditData); + + ParamAuditData safeAuditData = *auditData; + if (safeAuditData.memberNum > 0) { + size_t requiredSize = safeAuditData.memberNum * sizeof(uid_t); + if (remainingSize < requiredSize) { + safeAuditData.memberNum = remainingSize / sizeof(uid_t); + } + } + + return (AddParamSecurityNode(workSpace, &safeAuditData) == 0); + } +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::FuzzAddParamSecurityNode(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h new file mode 100644 index 000000000..4d39bfc74 --- /dev/null +++ b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_ADD_PARAM_SECURITY_NODE_H +#define TEST_FUZZTEST_ADD_PARAM_SECURITY_NODE_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "addparamsecuritynode_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init b/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/project.xml b/test/fuzztest/addparamsecuritynode_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/addparamsecuritynode_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp new file mode 100644 index 000000000..11266998d --- /dev/null +++ b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "addsecuritylabel_fuzzer.h" +#include +#include +#include "param_trie.h" +#include "param_manager.h" +#include "securec.h" + + +namespace OHOS { + bool FuzzAddSecurityLabel(const uint8_t* data, size_t size) + { + if (size < sizeof(ParamAuditData) + 1) { + return false; + } + + ParamAuditData auditData = {}; + if (memcpy_s(&auditData, sizeof(ParamAuditData), data, sizeof(ParamAuditData)) != 0) { + return false; + } + + size_t name_len = size - sizeof(ParamAuditData); + std::unique_ptr name_buf(new char[name_len + 1]); + if (memcpy_s(name_buf.get(), name_len + 1, data + sizeof(ParamAuditData), name_len) != 0) { + return false; + } + name_buf[name_len] = '\0'; + auditData.name = name_buf.get(); + + auditData.dacData.uid = *data % 10000; + auditData.dacData.gid = *(data + 1) % 10000; + auditData.dacData.mode = *(data + 2) % 0777; + auditData.dacData.paramType = *(data + 3) % 10; + + return (AddSecurityLabel(&auditData) == 0); + } +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::FuzzAddSecurityLabel(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h new file mode 100644 index 000000000..c5aa0d5ba --- /dev/null +++ b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_ADD_SECURITY_LABLE_H +#define TEST_FUZZTEST_ADD_SECURITY_LABLE_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "addsecuritylabel_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/corpus/init b/test/fuzztest/addsecuritylabel_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/addsecuritylabel_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/project.xml b/test/fuzztest/addsecuritylabel_fuzzer/project.xml new file mode 100644 index 000000000..a03232f21 --- /dev/null +++ b/test/fuzztest/addsecuritylabel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.cpp b/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.cpp new file mode 100644 index 000000000..5cb66cd21 --- /dev/null +++ b/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "checkappwatchpermission_fuzzer.h" +#include +#include +#include "init_utils.h" +#define private public +#include "watcher_manager.h" +#undef private +using namespace OHOS::init_param; + +namespace OHOS { +bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) + { + bool result = false; + std::string str(reinterpret_cast(data), size); + std::unique_ptr watcherManager = std::make_unique(0, true); + if (watcherManager->CheckAppWatchPermission(str)) { + result = true; + }; + return result; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzCheckAppWatchPermission(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.h b/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.h new file mode 100644 index 000000000..a75c318b3 --- /dev/null +++ b/test/fuzztest/checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_CHECK_APP_WATCH_PERMISSION_FUZZER_H +#define TEST_FUZZTEST_CHECK_APP_WATCH_PERMISSION_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "checkappwatchpermission_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/checkappwatchpermission_fuzzer/corpus/init b/test/fuzztest/checkappwatchpermission_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/checkappwatchpermission_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/checkappwatchpermission_fuzzer/project.xml b/test/fuzztest/checkappwatchpermission_fuzzer/project.xml new file mode 100644 index 000000000..9e35ed57f --- /dev/null +++ b/test/fuzztest/checkappwatchpermission_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/initworkspace_fuzzer/corpus/init b/test/fuzztest/initworkspace_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/initworkspace_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp new file mode 100644 index 000000000..076285bfb --- /dev/null +++ b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "initworkspace_fuzzer.h" +#include +#include +#include "param_trie.h" +#include "param_manager.h" +#include "securec.h" + + +namespace OHOS { + bool FuzzInitWorkSpace(const uint8_t* data, size_t size) + { + constexpr size_t min_size = sizeof(uint32_t) * 2; + if (size < min_size) { + return false; + } + + uint32_t spaceSize = 0; + if (memcpy_s(&spaceSize, sizeof(uint32_t), data, sizeof(uint32_t)) != 0) { + return false; + } + data += sizeof(uint32_t); + size -= sizeof(uint32_t); + + int onlyRead = 0; + if (memcpy_s(&onlyRead, sizeof(int), data, sizeof(int)) != 0) { + return false; + } + WorkSpace *workSpace = GetWorkSpace(0); + + return (InitWorkSpace(workSpace, onlyRead, spaceSize) == 0); + } +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::FuzzInitWorkSpace(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.h b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.h new file mode 100644 index 000000000..19f5ca4c0 --- /dev/null +++ b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_INIT_WORK_SPACE_H +#define TEST_FUZZTEST_INIT_WORK_SPACE_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "initworkspace_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/initworkspace_fuzzer/project.xml b/test/fuzztest/initworkspace_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/initworkspace_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + -- Gitee From 36ba6e0faf086734d616433b5689faac2f4d25e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 10:59:07 +0000 Subject: [PATCH 03/15] =?UTF-8?q?Signed-off-by:=20=E4=B9=BE=E9=98=B3?= =?UTF-8?q?=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../mountonewithfstabfile_fuzzer/corpus/init | 16 +++++++ .../mountonewithfstabfile_fuzzer.cpp | 46 +++++++++++++++++++ .../mountonewithfstabfile_fuzzer.h | 20 ++++++++ .../mountonewithfstabfile_fuzzer/project.xml | 25 ++++++++++ test/fuzztest/onstop_fuzzer/corpus/init | 16 +++++++ test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp | 43 +++++++++++++++++ test/fuzztest/onstop_fuzzer/onstop_fuzzer.h | 20 ++++++++ test/fuzztest/onstop_fuzzer/project.xml | 25 ++++++++++ 8 files changed, 211 insertions(+) create mode 100644 test/fuzztest/mountonewithfstabfile_fuzzer/corpus/init create mode 100644 test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp create mode 100644 test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.h create mode 100644 test/fuzztest/mountonewithfstabfile_fuzzer/project.xml create mode 100644 test/fuzztest/onstop_fuzzer/corpus/init create mode 100644 test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp create mode 100644 test/fuzztest/onstop_fuzzer/onstop_fuzzer.h create mode 100644 test/fuzztest/onstop_fuzzer/project.xml diff --git a/test/fuzztest/mountonewithfstabfile_fuzzer/corpus/init b/test/fuzztest/mountonewithfstabfile_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/mountonewithfstabfile_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp new file mode 100644 index 000000000..a95c0410a --- /dev/null +++ b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "mountonewithfstabfile_fuzzer.h" +#include "securec.h" +#include +#include +#include +#include "fs_manager.h" +#include + +namespace OHOS { + bool FuzzMountOneWithFstabFile(const uint8_t* data, size_t size) { + char fstabPath[] = "/tmp/fuzz_fstab_1"; + int fd = mkstemp(fstabPath); + if (fd < 0) { + return false; + } + + std::string str(reinterpret_cast(data), size); + + int ret = MountOneWithFstabFile(fstabPath, str.c_str(), false); + unlink(fstabPath); + if (ret == 0) { + return true; + } + return false; + } +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::FuzzMountOneWithFstabFile(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.h b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.h new file mode 100644 index 000000000..fd3a697d3 --- /dev/null +++ b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_MOUNT_ONE_WITH_FSTABFILE_H +#define TEST_FUZZTEST_MOUNT_ONE_WITH_FSTABFILE_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "mountoneWithfstabfile_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/mountonewithfstabfile_fuzzer/project.xml b/test/fuzztest/mountonewithfstabfile_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/mountonewithfstabfile_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + diff --git a/test/fuzztest/onstop_fuzzer/corpus/init b/test/fuzztest/onstop_fuzzer/corpus/init new file mode 100644 index 000000000..8eb5a7d6e --- /dev/null +++ b/test/fuzztest/onstop_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp new file mode 100644 index 000000000..5acdd3f20 --- /dev/null +++ b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "onstop_fuzzer.h" +#include +#include +#include "init_utils.h" +#define protected public +#include "watcher_manager.h" +#undef protected +using namespace OHOS::init_param; + +namespace OHOS { +bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) + { + std::unique_ptr watcherManager = std::make_unique(0, true); + uint32_t id = static_cast(*data); + uint32_t watcherId = 0; + sptr watcher = {0}; + watcherManager->AddRemoteWatcher(id, watcherId, watcher); + watcherManager->OnStop(); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::FuzzCheckAppWatchPermission(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.h b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.h new file mode 100644 index 000000000..28d288f46 --- /dev/null +++ b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_ON_STOP_FUZZER_H +#define TEST_FUZZTEST_ON_STOP_FUZZER_H +#include "fuzz_utils.h" +#define FUZZ_PROJECT_NAME "onstop_fuzzer" +#endif \ No newline at end of file diff --git a/test/fuzztest/onstop_fuzzer/project.xml b/test/fuzztest/onstop_fuzzer/project.xml new file mode 100644 index 000000000..949d03efd --- /dev/null +++ b/test/fuzztest/onstop_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 100 + + 30 + + 2048 + + -- Gitee From 1a7ce85d940f49d04b4c1b9543e2070820fceb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 11:01:01 +0000 Subject: [PATCH 04/15] =?UTF-8?q?Signed-off-by:=20=E4=B9=BE=E9=98=B3?= =?UTF-8?q?=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addremotewatcher_fuzzer/addremotewatcher_fuzzer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/fuzztest/addremotewatcher_fuzzer/addremotewatcher_fuzzer.cpp b/test/fuzztest/addremotewatcher_fuzzer/addremotewatcher_fuzzer.cpp index fff638a73..31c45160a 100644 --- a/test/fuzztest/addremotewatcher_fuzzer/addremotewatcher_fuzzer.cpp +++ b/test/fuzztest/addremotewatcher_fuzzer/addremotewatcher_fuzzer.cpp @@ -26,7 +26,8 @@ namespace OHOS { std::unique_ptr watcherManager = std::make_unique(0, true); uint32_t id = static_cast(*data); uint32_t watcherId = 0; - if (!watcherManager->AddRemoteWatcher(id, watcherId, nullptr)) { + sptr watcher = {0}; + if (!watcherManager->AddRemoteWatcher(id, watcherId, watcher)) { result = true; }; return result; -- Gitee From 46b01ad67285ca12316072d97ba8df5f57da6946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 11:25:08 +0000 Subject: [PATCH 05/15] =?UTF-8?q?update=20test/fuzztest/BUILD.gn.=20Signed?= =?UTF-8?q?-off-by:=20=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/BUILD.gn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 94e8734c9..358d45234 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -3599,10 +3599,14 @@ group("fuzztest") { ":AclGetDiskSNFuzzTest", ":AclGetSerialFuzzTest", ":AddRemoteWatcherFuzzTest", + ":AddParamEntryFuzzTest", + ":AddParamSecurityNodeFuzzTest", + ":AddSecurityLabelFuzzTest", ":AddWatcherFuzzTest", ":BuildControlMessageFuzzTest", ":ChangeSysAttributePermissionsFuzzTest", ":CheckAndCreatFileFuzzTest", + ":CheckAppWatchPermissionFuzzTest", ":CmdClientInitFuzzTest", ":CmdServiceProcessDelClientFuzzTest", ":DecodeGidFuzzTest", @@ -3679,6 +3683,7 @@ group("fuzztest") { ":HookMgrGetStagesCntFuzzTest", ":HookMgrTraversalFuzzTest", ":IsSupportedFilesystemFuzzTest", + ":InitWorkSpaceFuzzTest", ":LoadFscryptPolicyFuzzTest", ":LoadFstabFromCommandLineFuzzTest", ":LoadParamFromCmdLineFuzzTest", @@ -3692,6 +3697,8 @@ group("fuzztest") { ":MountAllWithFstabFileFuzzTest", ":MountAllWithFstabFuzzTest", ":MountOneItemFuzzTest", + ":MountOneWithFstabFileFuzzTest", + ":OnStopFuzzTest", ":ParseFstabPerLineFuzzTest", ":ParseUeventConfigFuzzTest", ":ParseUeventdConfigFileFuzzTest", -- Gitee From 6e399b9957c10aeeec767238c95481f49cf5da0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 11:28:10 +0000 Subject: [PATCH 06/15] =?UTF-8?q?update=20test/fuzztest/BUILD.gn.=20Signed?= =?UTF-8?q?-off-by:=20=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/BUILD.gn | 251 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 358d45234..c5e4c549d 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -3590,6 +3590,257 @@ ohos_fuzztest("SplitStringFuzzTest") { defines = [ "STARTUP_INIT_TEST" ] } +ohos_fuzztest("MountOneWithFstabFileFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//base/startup/init/test/fuzztest/mountonewithfstabfile_fuzzer" + + include_dirs = [ + "//base/startup/init/interfaces/innerkits/fs_manager", + "//base/startup/init/interfaces/innerkits/include/fs_manager", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static",] + external_deps = [ + "bounds_checking_function:libsec_static", + "cJSON:cjson", + ] + external_deps += [ "hilog:libhilog" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp", + ] + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("AddParamSecurityNodeFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//base/startup/init/test/fuzztest/addparamsecuritynode_fuzzer" + + include_dirs = [ + "//base/startup/init/services/param/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/services/param:parameter",] + external_deps = [ + "bounds_checking_function:libsec_static", + ] + external_deps += [ "hilog:libhilog" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp", + ] + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("AddParamEntryFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//base/startup/init/test/fuzztest/addparamentry_fuzzer" + + include_dirs = [ + "//base/startup/init/services/param/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/services/param:parameter",] + external_deps = [ + "bounds_checking_function:libsec_static", + ] + external_deps += [ "hilog:libhilog" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "addparamentry_fuzzer/addparamentry_fuzzer.cpp", + ] + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("AddSecurityLabelFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//base/startup/init/test/fuzztest/addsecuritylabel_fuzzer" + + include_dirs = [ + "//base/startup/init/services/param/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/services/param:parameter",] + external_deps = [ + "bounds_checking_function:libsec_static", + ] + external_deps += [ "hilog:libhilog" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp", + ] + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("InitWorkSpaceFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//base/startup/init/test/fuzztest/initworkspace_fuzzer" + + include_dirs = [ + "//base/startup/init/services/param/include", + "//base/startup/init/test/fuzztest/utils/include", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/services/param:parameter",] + external_deps = [ + "bounds_checking_function:libsec_static", + ] + external_deps += [ "hilog:libhilog" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "initworkspace_fuzzer/initworkspace_fuzzer.cpp", + ] + defines = [ "STARTUP_INIT_TEST" ] +} + +ohos_fuzztest("CheckAppWatchPermissionFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/checkappwatchpermission_fuzzer" + + sources = [ + "//base/startup/init/services/param/linux/param_message.c", + "//base/startup/init/services/param/watcher/proxy/watcher_manager.cpp", + ] + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + "//base/startup/init/services/param/watcher/proxy", + "//base/startup/init/services/param/watcher/include", + "//base/startup/init/services/param/include", + "//base/startup/init/interfaces/innerkits/include/param", + "//base/startup/init/services/param/linux", + "//base/startup/init/services/loopevent/include", + "//base/startup/init/services/param/watcher/agent", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/interfaces/innerkits/:param_watcher_stub", + "//base/startup/init/services/log:agent_log", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_single", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + if (init_paramwatcher_hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + } + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources += [ "checkappwatchpermission_fuzzer/checkappwatchpermission_fuzzer.cpp" ] + defines = [ "STARTUP_INIT_TEST" ] + if (init_paramwatcher_hicollie_enable) { + defines += [ "HICOLLIE_ENABLE" ] + } +} + +ohos_fuzztest("OnStopFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//base/startup/init/test/fuzztest/onstop_fuzzer" + + sources = [ + "//base/startup/init/services/param/linux/param_message.c", + "//base/startup/init/services/param/watcher/proxy/watcher_manager.cpp", + ] + include_dirs = [ + "//base/startup/init/interfaces/innerkits/include", + "//base/startup/init/test/fuzztest/utils/include", + "//base/startup/init/services/param/watcher/proxy", + "//base/startup/init/services/param/watcher/include", + "//base/startup/init/services/param/include", + "//base/startup/init/interfaces/innerkits/include/param", + "//base/startup/init/services/param/linux", + "//base/startup/init/services/loopevent/include", + "//base/startup/init/services/param/watcher/agent", + ] + + deps = [ + "//base/startup/init/interfaces/innerkits:libbegetutil", + "//base/startup/init/interfaces/innerkits/:param_watcher_stub", + "//base/startup/init/services/log:agent_log", + ] + external_deps = [ + "bounds_checking_function:libsec_static", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_single", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + if (init_paramwatcher_hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + } + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources += [ "onstop_fuzzer/onstop_fuzzer.cpp" ] + defines = [ "STARTUP_INIT_TEST" ] + if (init_paramwatcher_hicollie_enable) { + defines += [ "HICOLLIE_ENABLE" ] + } + ############################################################################################## group("fuzztest") { testonly = true -- Gitee From 52b27ac46bce07973ee6e6390321d9df97c55ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:10:00 +0000 Subject: [PATCH 07/15] =?UTF-8?q?update=20test/fuzztest/addparamentry=5Ffu?= =?UTF-8?q?zzer/addparamentry=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE?= =?UTF-8?q?=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addparamentry_fuzzer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp index b139e9cfe..0b5237064 100644 --- a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp +++ b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp @@ -28,20 +28,20 @@ namespace OHOS { return false; } - size_t split_pos = size / 2; - if (split_pos == 0) { - split_pos = 1; + size_t splitpos = size / 2; + if (splitpos == 0) { + splitpos = 1; } - std::unique_ptr name(new char[split_pos + 1]); - if (memcpy_s(name.get(), split_pos + 1, data, split_pos) != 0) { + std::unique_ptr name(new char[splitpos + 1]); + if (memcpy_s(name.get(), splitpos + 1, data, splitpos) != 0) { return false; } - name[split_pos] = '\0'; + name[splitpos] = '\0'; - size_t value_size = size - split_pos; + size_t value_size = size - splitpos; std::unique_ptr value(new char[value_size + 1]); - if (memcpy_s(value.get(), value_size + 1, data + split_pos, value_size) != 0) { + if (memcpy_s(value.get(), value_size + 1, data + splitpos, value_size) != 0) { return false; } value[value_size] = '\0'; -- Gitee From 0ccd74ec94ce672ec41fb55380ff00347ad76c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:12:13 +0000 Subject: [PATCH 08/15] =?UTF-8?q?update=20test/fuzztest/addsecuritylabel?= =?UTF-8?q?=5Ffuzzer/addsecuritylabel=5Ffuzzer.cpp.=20Signed-off-by:=20?= =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp index 11266998d..6d0450d45 100644 --- a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp +++ b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp @@ -33,12 +33,12 @@ namespace OHOS { return false; } - size_t name_len = size - sizeof(ParamAuditData); - std::unique_ptr name_buf(new char[name_len + 1]); - if (memcpy_s(name_buf.get(), name_len + 1, data + sizeof(ParamAuditData), name_len) != 0) { + size_t namelen = size - sizeof(ParamAuditData); + std::unique_ptr name_buf(new char[namelen + 1]); + if (memcpy_s(name_buf.get(), namelen + 1, data + sizeof(ParamAuditData), namelen) != 0) { return false; } - name_buf[name_len] = '\0'; + name_buf[namelen] = '\0'; auditData.name = name_buf.get(); auditData.dacData.uid = *data % 10000; -- Gitee From 1135a9d76ea42e645f89bf8c5eff8f2156bfb06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:13:31 +0000 Subject: [PATCH 09/15] =?UTF-8?q?update=20test/fuzztest/initworkspace=5Ffu?= =?UTF-8?q?zzer/initworkspace=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE?= =?UTF-8?q?=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp index 076285bfb..ac4ded0fd 100644 --- a/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp +++ b/test/fuzztest/initworkspace_fuzzer/initworkspace_fuzzer.cpp @@ -24,8 +24,8 @@ namespace OHOS { bool FuzzInitWorkSpace(const uint8_t* data, size_t size) { - constexpr size_t min_size = sizeof(uint32_t) * 2; - if (size < min_size) { + constexpr size_t minsize = sizeof(uint32_t) * 2; + if (size < minsize) { return false; } -- Gitee From 7eb6377bb17ae899e188425a30b9520f87002c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:15:09 +0000 Subject: [PATCH 10/15] =?UTF-8?q?update=20test/fuzztest/addparamentry=5Ffu?= =?UTF-8?q?zzer/addparamentry=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE?= =?UTF-8?q?=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../addparamentry_fuzzer/addparamentry_fuzzer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp index 0b5237064..1f3c9287e 100644 --- a/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp +++ b/test/fuzztest/addparamentry_fuzzer/addparamentry_fuzzer.cpp @@ -39,12 +39,12 @@ namespace OHOS { } name[splitpos] = '\0'; - size_t value_size = size - splitpos; - std::unique_ptr value(new char[value_size + 1]); - if (memcpy_s(value.get(), value_size + 1, data + splitpos, value_size) != 0) { + size_t valuesize = size - splitpos; + std::unique_ptr value(new char[valuesize + 1]); + if (memcpy_s(value.get(), valuesize + 1, data + splitpos, valuesize) != 0) { return false; } - value[value_size] = '\0'; + value[valuesize] = '\0'; uint32_t index = 0; if (memcpy_s(&index, sizeof(uint32_t), data, sizeof(uint32_t)) != 0) { -- Gitee From 3521e816e8dc61d8eb0abd67ba578e6de5c9d573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:19:36 +0000 Subject: [PATCH 11/15] =?UTF-8?q?update=20test/fuzztest/onstop=5Ffuzzer/on?= =?UTF-8?q?stop=5Ffuzzer.cpp.=20Signed-off-by:=20=E4=B9=BE=E9=98=B3?= =?UTF-8?q?=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp index 5acdd3f20..7d62a847d 100644 --- a/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp +++ b/test/fuzztest/onstop_fuzzer/onstop_fuzzer.cpp @@ -22,7 +22,7 @@ using namespace OHOS::init_param; namespace OHOS { -bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) + bool FuzzCheckAppWatchPermission(const uint8_t* data, size_t size) { std::unique_ptr watcherManager = std::make_unique(0, true); uint32_t id = static_cast(*data); -- Gitee From b2bfe1e237e9e331171c4f20df732348eabc5b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:20:41 +0000 Subject: [PATCH 12/15] =?UTF-8?q?update=20test/fuzztest/mountonewithfstabf?= =?UTF-8?q?ile=5Ffuzzer/mountonewithfstabfile=5Ffuzzer.cpp.=20Signed-off-b?= =?UTF-8?q?y:=20=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- .../mountonewithfstabfile_fuzzer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp index a95c0410a..0573214b1 100644 --- a/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp +++ b/test/fuzztest/mountonewithfstabfile_fuzzer/mountonewithfstabfile_fuzzer.cpp @@ -21,7 +21,8 @@ #include namespace OHOS { - bool FuzzMountOneWithFstabFile(const uint8_t* data, size_t size) { + bool FuzzMountOneWithFstabFile(const uint8_t* data, size_t size) + { char fstabPath[] = "/tmp/fuzz_fstab_1"; int fd = mkstemp(fstabPath); if (fd < 0) { -- Gitee From f4c3517b1466443a468feff3aef2721a845869f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:51:09 +0000 Subject: [PATCH 13/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/addparamsecuritynode=5Ffuzzer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addparamsecuritynode_fuzzer.cpp | 51 ------------------- .../addparamsecuritynode_fuzzer.h | 20 -------- .../addparamsecuritynode_fuzzer/corpus/init | 16 ------ .../addparamsecuritynode_fuzzer/project.xml | 25 --------- 4 files changed, 112 deletions(-) delete mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp delete mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h delete mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/corpus/init delete mode 100644 test/fuzztest/addparamsecuritynode_fuzzer/project.xml diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp deleted file mode 100644 index 2e886fe8e..000000000 --- a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "addparamsecuritynode_fuzzer.h" -#include -#include -#include "param_trie.h" -#include "param_manager.h" - - -namespace OHOS { - bool FuzzAddParamSecurityNode(const uint8_t* data, size_t size) - { - if (size < sizeof(ParamAuditData)) { - return false; - } - - WorkSpace *workSpace = GetWorkSpace(0); - - const ParamAuditData* auditData = reinterpret_cast(data); - size_t remainingSize = size - sizeof(ParamAuditData); - - ParamAuditData safeAuditData = *auditData; - if (safeAuditData.memberNum > 0) { - size_t requiredSize = safeAuditData.memberNum * sizeof(uid_t); - if (remainingSize < requiredSize) { - safeAuditData.memberNum = remainingSize / sizeof(uid_t); - } - } - - return (AddParamSecurityNode(workSpace, &safeAuditData) == 0); - } -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - OHOS::FuzzAddParamSecurityNode(data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h b/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h deleted file mode 100644 index 4d39bfc74..000000000 --- a/test/fuzztest/addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.h +++ /dev/null @@ -1,20 +0,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. - */ - -#ifndef TEST_FUZZTEST_ADD_PARAM_SECURITY_NODE_H -#define TEST_FUZZTEST_ADD_PARAM_SECURITY_NODE_H -#include "fuzz_utils.h" -#define FUZZ_PROJECT_NAME "addparamsecuritynode_fuzzer" -#endif \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init b/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6e..000000000 --- a/test/fuzztest/addparamsecuritynode_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,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. - */ - -FUZZ \ No newline at end of file diff --git a/test/fuzztest/addparamsecuritynode_fuzzer/project.xml b/test/fuzztest/addparamsecuritynode_fuzzer/project.xml deleted file mode 100644 index 949d03efd..000000000 --- a/test/fuzztest/addparamsecuritynode_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 100 - - 30 - - 2048 - - -- Gitee From 8131308769ccc4f5b1deecaa1ba12d332942b740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:51:28 +0000 Subject: [PATCH 14/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/addsecuritylabel=5Ffuzzer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addsecuritylabel_fuzzer.cpp | 57 ------------------- .../addsecuritylabel_fuzzer.h | 20 ------- .../addsecuritylabel_fuzzer/corpus/init | 16 ------ .../addsecuritylabel_fuzzer/project.xml | 25 -------- 4 files changed, 118 deletions(-) delete mode 100644 test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp delete mode 100644 test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h delete mode 100644 test/fuzztest/addsecuritylabel_fuzzer/corpus/init delete mode 100644 test/fuzztest/addsecuritylabel_fuzzer/project.xml diff --git a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp deleted file mode 100644 index 6d0450d45..000000000 --- a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "addsecuritylabel_fuzzer.h" -#include -#include -#include "param_trie.h" -#include "param_manager.h" -#include "securec.h" - - -namespace OHOS { - bool FuzzAddSecurityLabel(const uint8_t* data, size_t size) - { - if (size < sizeof(ParamAuditData) + 1) { - return false; - } - - ParamAuditData auditData = {}; - if (memcpy_s(&auditData, sizeof(ParamAuditData), data, sizeof(ParamAuditData)) != 0) { - return false; - } - - size_t namelen = size - sizeof(ParamAuditData); - std::unique_ptr name_buf(new char[namelen + 1]); - if (memcpy_s(name_buf.get(), namelen + 1, data + sizeof(ParamAuditData), namelen) != 0) { - return false; - } - name_buf[namelen] = '\0'; - auditData.name = name_buf.get(); - - auditData.dacData.uid = *data % 10000; - auditData.dacData.gid = *(data + 1) % 10000; - auditData.dacData.mode = *(data + 2) % 0777; - auditData.dacData.paramType = *(data + 3) % 10; - - return (AddSecurityLabel(&auditData) == 0); - } -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - OHOS::FuzzAddSecurityLabel(data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h b/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h deleted file mode 100644 index c5aa0d5ba..000000000 --- a/test/fuzztest/addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.h +++ /dev/null @@ -1,20 +0,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. - */ - -#ifndef TEST_FUZZTEST_ADD_SECURITY_LABLE_H -#define TEST_FUZZTEST_ADD_SECURITY_LABLE_H -#include "fuzz_utils.h" -#define FUZZ_PROJECT_NAME "addsecuritylabel_fuzzer" -#endif \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/corpus/init b/test/fuzztest/addsecuritylabel_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6e..000000000 --- a/test/fuzztest/addsecuritylabel_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,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. - */ - -FUZZ \ No newline at end of file diff --git a/test/fuzztest/addsecuritylabel_fuzzer/project.xml b/test/fuzztest/addsecuritylabel_fuzzer/project.xml deleted file mode 100644 index a03232f21..000000000 --- a/test/fuzztest/addsecuritylabel_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 100 - - 30 - - 2048 - - -- Gitee From ddd7fa1c4f9bfddcfbe068f3aedab95f78d59a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Wed, 11 Jun 2025 12:54:42 +0000 Subject: [PATCH 15/15] =?UTF-8?q?update=20test/fuzztest/BUILD.gn.=20Signed?= =?UTF-8?q?-off-by:=20=E4=B9=BE=E9=98=B3=E7=86=A0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 乾阳熠 --- test/fuzztest/BUILD.gn | 66 ++---------------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index c5e4c549d..57b498a03 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -3621,37 +3621,7 @@ ohos_fuzztest("MountOneWithFstabFileFuzzTest") { ] defines = [ "STARTUP_INIT_TEST" ] } - -ohos_fuzztest("AddParamSecurityNodeFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//base/startup/init/test/fuzztest/addparamsecuritynode_fuzzer" - - include_dirs = [ - "//base/startup/init/services/param/include", - "//base/startup/init/test/fuzztest/utils/include", - ] - - deps = [ - "//base/startup/init/interfaces/innerkits:libbegetutil", - "//base/startup/init/services/param:parameter",] - external_deps = [ - "bounds_checking_function:libsec_static", - ] - external_deps += [ "hilog:libhilog" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ - "addparamsecuritynode_fuzzer/addparamsecuritynode_fuzzer.cpp", - ] - defines = [ "STARTUP_INIT_TEST" ] -} - + ohos_fuzztest("AddParamEntryFuzzTest") { module_out_path = module_output_path fuzz_config_file = @@ -3681,37 +3651,7 @@ ohos_fuzztest("AddParamEntryFuzzTest") { ] defines = [ "STARTUP_INIT_TEST" ] } - -ohos_fuzztest("AddSecurityLabelFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "//base/startup/init/test/fuzztest/addsecuritylabel_fuzzer" - - include_dirs = [ - "//base/startup/init/services/param/include", - "//base/startup/init/test/fuzztest/utils/include", - ] - - deps = [ - "//base/startup/init/interfaces/innerkits:libbegetutil", - "//base/startup/init/services/param:parameter",] - external_deps = [ - "bounds_checking_function:libsec_static", - ] - external_deps += [ "hilog:libhilog" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ - "addsecuritylabel_fuzzer/addsecuritylabel_fuzzer.cpp", - ] - defines = [ "STARTUP_INIT_TEST" ] -} - + ohos_fuzztest("InitWorkSpaceFuzzTest") { module_out_path = module_output_path fuzz_config_file = @@ -3851,8 +3791,6 @@ group("fuzztest") { ":AclGetSerialFuzzTest", ":AddRemoteWatcherFuzzTest", ":AddParamEntryFuzzTest", - ":AddParamSecurityNodeFuzzTest", - ":AddSecurityLabelFuzzTest", ":AddWatcherFuzzTest", ":BuildControlMessageFuzzTest", ":ChangeSysAttributePermissionsFuzzTest", -- Gitee