From 98ba1a0106670852cc16cd975de9da4bfb2fc184 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 23 May 2022 16:40:42 +0800 Subject: [PATCH 01/14] Signed-off-by: lovechinamo Changes to be committed: --- .../time_manager/include/ntp_update_time.h | 1 + services/time_manager/src/ntp_update_time.cpp | 42 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/services/time_manager/include/ntp_update_time.h b/services/time_manager/include/ntp_update_time.h index 4b025fee..303e1c7c 100644 --- a/services/time_manager/include/ntp_update_time.h +++ b/services/time_manager/include/ntp_update_time.h @@ -37,6 +37,7 @@ public: void SetSystemTime(); void Stop(); void Init(); + int32_t MonitorNetwork(); private: bool GetAutoTimeInfoFromFile(autoTimeInfo &info); bool SaveAutoTimeInfoToFile(autoTimeInfo &info); diff --git a/services/time_manager/src/ntp_update_time.cpp b/services/time_manager/src/ntp_update_time.cpp index 6febfd2b..33fcd2ab 100644 --- a/services/time_manager/src/ntp_update_time.cpp +++ b/services/time_manager/src/ntp_update_time.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "ntp_trusted_time.h" #include "time_common.h" @@ -66,15 +67,20 @@ void NtpUpdateTime::Init() return; } } - // observer net connection - NetSpecifier netSpecifier; - NetAllCapabilities netAllCapabilities; - netAllCapabilities.netCaps_.insert(NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET); - netSpecifier.ident_ = "wifi"; - netSpecifier.netCapabilities_ = netAllCapabilities; - sptr specifier = new NetSpecifier(netSpecifier); - sptr observer = new NetConnCallbackObserver; - DelayedSingleton::GetInstance()->RegisterNetConnCallback(specifier, observer, 0); + + std::thread th = std::thread([this]() { + constexpr int RETRY_MAX_TIMES = 100; + int retryCount = 0; + constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second + do { + if (this->MonitorNetwork() == NET_CONN_SUCCESS) { + break; + } + retryCount++; + usleep(RETRY_TIME_INTERVAL_MILLISECOND); + } while (retryCount < RETRY_MAX_TIMES); + }); + th.detach(); int32_t timerType = ITimerManager::TimerType::ELAPSED_REALTIME; auto callback = [this](uint64_t id) { @@ -85,8 +91,26 @@ void NtpUpdateTime::Init() RefreshNextTriggerTime(); TIME_HILOGD(TIME_MODULE_SERVICE, "Ntp update triggertime: %{public}" PRId64 "", nextTriggerTime_); TimeService::GetInstance()->StartTimer(timerId_, nextTriggerTime_); + } +int32_t NtpUpdateTime::MonitorNetwork() +{ + // observer net connection + TIME_HILOGD(TIME_MODULE_SERVICE,"NtpUpdateTime::MonitorNetwork"); + NetSpecifier netSpecifier; + NetAllCapabilities netAllCapabilities; + netAllCapabilities.netCaps_.insert(NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET); + netSpecifier.netCapabilities_ = netAllCapabilities; + sptr specifier = new NetSpecifier(netSpecifier); + sptr observer = new NetConnCallbackObserver; + int nRet = DelayedSingleton::GetInstance()->RegisterNetConnCallback(specifier, observer, 0); + TIME_HILOGD(TIME_MODULE_SERVICE,"RegisterNetConnCallback retcode= %{public}d", nRet); + + return nRet; +} + + void NtpUpdateTime::SubscriberNITZTimeChangeCommonEvent() { // Broadcast subscription -- Gitee From 7a3ce8ab7a2c8c498f95850f99d5ae5565a9466b Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 23 May 2022 17:00:36 +0800 Subject: [PATCH 02/14] Signed-off-by: lovechinamo Changes to be committed: --- services/time_manager/src/ntp_update_time.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/time_manager/src/ntp_update_time.cpp b/services/time_manager/src/ntp_update_time.cpp index 33fcd2ab..8472b3a2 100644 --- a/services/time_manager/src/ntp_update_time.cpp +++ b/services/time_manager/src/ntp_update_time.cpp @@ -73,10 +73,11 @@ void NtpUpdateTime::Init() int retryCount = 0; constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second do { - if (this->MonitorNetwork() == NET_CONN_SUCCESS) { + if (this->MonitorNetwork() == NET_CONN_SUCCESS) + { break; - } - retryCount++; + } + retryCount++; usleep(RETRY_TIME_INTERVAL_MILLISECOND); } while (retryCount < RETRY_MAX_TIMES); }); @@ -91,13 +92,12 @@ void NtpUpdateTime::Init() RefreshNextTriggerTime(); TIME_HILOGD(TIME_MODULE_SERVICE, "Ntp update triggertime: %{public}" PRId64 "", nextTriggerTime_); TimeService::GetInstance()->StartTimer(timerId_, nextTriggerTime_); - } int32_t NtpUpdateTime::MonitorNetwork() { // observer net connection - TIME_HILOGD(TIME_MODULE_SERVICE,"NtpUpdateTime::MonitorNetwork"); + TIME_HILOGD(TIME_MODULE_SERVICE, "NtpUpdateTime::MonitorNetwork"); NetSpecifier netSpecifier; NetAllCapabilities netAllCapabilities; netAllCapabilities.netCaps_.insert(NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET); @@ -105,7 +105,7 @@ int32_t NtpUpdateTime::MonitorNetwork() sptr specifier = new NetSpecifier(netSpecifier); sptr observer = new NetConnCallbackObserver; int nRet = DelayedSingleton::GetInstance()->RegisterNetConnCallback(specifier, observer, 0); - TIME_HILOGD(TIME_MODULE_SERVICE,"RegisterNetConnCallback retcode= %{public}d", nRet); + TIME_HILOGD(TIME_MODULE_SERVICE, "RegisterNetConnCallback retcode= %{public}d", nRet); return nRet; } -- Gitee From ac79fbed0dfe09be1d95db6bb6bcbe1fc1ee54b2 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 23 May 2022 17:16:04 +0800 Subject: [PATCH 03/14] Signed-off-by: lovechinamo Changes to be committed: --- services/time_manager/src/ntp_update_time.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/time_manager/src/ntp_update_time.cpp b/services/time_manager/src/ntp_update_time.cpp index 8472b3a2..b1f3cc10 100644 --- a/services/time_manager/src/ntp_update_time.cpp +++ b/services/time_manager/src/ntp_update_time.cpp @@ -73,12 +73,11 @@ void NtpUpdateTime::Init() int retryCount = 0; constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second do { - if (this->MonitorNetwork() == NET_CONN_SUCCESS) - { + if (this->MonitorNetwork() == NET_CONN_SUCCESS){ break; } - retryCount++; - usleep(RETRY_TIME_INTERVAL_MILLISECOND); + retryCount++; + usleep(RETRY_TIME_INTERVAL_MILLISECOND); } while (retryCount < RETRY_MAX_TIMES); }); th.detach(); -- Gitee From 451003a816d684c8151b83160c94e76ca6226095 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 23 May 2022 17:26:52 +0800 Subject: [PATCH 04/14] Signed-off-by: lovechinamo Changes to be committed: --- services/time_manager/src/ntp_update_time.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/time_manager/src/ntp_update_time.cpp b/services/time_manager/src/ntp_update_time.cpp index b1f3cc10..f21b60b9 100644 --- a/services/time_manager/src/ntp_update_time.cpp +++ b/services/time_manager/src/ntp_update_time.cpp @@ -69,16 +69,17 @@ void NtpUpdateTime::Init() } std::thread th = std::thread([this]() { - constexpr int RETRY_MAX_TIMES = 100; - int retryCount = 0; - constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second - do { - if (this->MonitorNetwork() == NET_CONN_SUCCESS){ + constexpr int RETRY_MAX_TIMES = 100; + int retryCount = 0; + constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second + do { + if (this->MonitorNetwork() == NET_CONN_SUCCESS) + { break; } retryCount++; usleep(RETRY_TIME_INTERVAL_MILLISECOND); - } while (retryCount < RETRY_MAX_TIMES); + } while (retryCount < RETRY_MAX_TIMES); }); th.detach(); -- Gitee From 5a2a39a1021da7aa455e69cb776cbddc732c6afe Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 23 May 2022 17:37:27 +0800 Subject: [PATCH 05/14] Signed-off-by: lovechinamo Changes to be committed: --- services/time_manager/src/ntp_update_time.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/time_manager/src/ntp_update_time.cpp b/services/time_manager/src/ntp_update_time.cpp index f21b60b9..837924d9 100644 --- a/services/time_manager/src/ntp_update_time.cpp +++ b/services/time_manager/src/ntp_update_time.cpp @@ -73,9 +73,8 @@ void NtpUpdateTime::Init() int retryCount = 0; constexpr int RETRY_TIME_INTERVAL_MILLISECOND = 1 * 1000 * 1000; // retry after 2 second do { - if (this->MonitorNetwork() == NET_CONN_SUCCESS) - { - break; + if (this->MonitorNetwork() == NET_CONN_SUCCESS) { + break; } retryCount++; usleep(RETRY_TIME_INTERVAL_MILLISECOND); -- Gitee From 98a8f4ed64b99803cf5b83aedebe61eee7878859 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 24 May 2022 17:05:48 +0800 Subject: [PATCH 06/14] Signed-off-by: lovechinamo Changes to be committed: --- bundle.json | 3 +- test/fuzztest/BUILD.gn | 20 ++++ test/fuzztest/timeservice_fuzzer/BUILD.gn | 97 +++++++++++++++++++ test/fuzztest/timeservice_fuzzer/corpus/init | 1 + test/fuzztest/timeservice_fuzzer/project.xml | 25 +++++ .../timeservice_fuzzer/timeservice_fuzzer.cpp | 69 +++++++++++++ .../timeservice_fuzzer/timeservice_fuzzer.h | 22 +++++ 7 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 test/fuzztest/BUILD.gn create mode 100644 test/fuzztest/timeservice_fuzzer/BUILD.gn create mode 100644 test/fuzztest/timeservice_fuzzer/corpus/init create mode 100644 test/fuzztest/timeservice_fuzzer/project.xml create mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp create mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h diff --git a/bundle.json b/bundle.json index 9073a4cd..e578a5a4 100644 --- a/bundle.json +++ b/bundle.json @@ -69,7 +69,8 @@ } ], "test": [ - "//base/miscservices/time/services/time_manager/test:TimeServiceTest" + "//base/miscservices/time/services/time_manager/test:TimeServiceTest", + "//base/miscservices/time/test/fuzztest:fuzztest" ] } } diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn new file mode 100644 index 00000000..6b3cb58d --- /dev/null +++ b/test/fuzztest/BUILD.gn @@ -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. + +import("//base/miscservices/time/time.gni") + +group("fuzztest") { + testonly = true + + deps = [ "timeservice_fuzzer:fuzztest" ] +} diff --git a/test/fuzztest/timeservice_fuzzer/BUILD.gn b/test/fuzztest/timeservice_fuzzer/BUILD.gn new file mode 100644 index 00000000..63c9c8df --- /dev/null +++ b/test/fuzztest/timeservice_fuzzer/BUILD.gn @@ -0,0 +1,97 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("TimeServiceFuzzTest") { + module_out_path = "miscservices/time" + + fuzz_config_file = "//base/miscservices/time/test/fuzztest/timeservice_fuzzer" + + include_dirs = [ + "//base/miscservices/time/services/time_manager/include", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + "//foundation/aafwk/standard/interfaces/innerkits/wantagent/include", + "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", + "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include", + "//foundation/aafwk/standard/ability_base/interfaces/inner_api/configuration/include", + "//base/global/resource_management/interfaces/inner_api/include", + "//foundation/aafwk/standard/ability_base/interfaces/inner_api/want/include", + "//foundation/aafwk/standard/ability_base/interfaces/inner_api/uri/include", + "//foundation/aafwk/standard/ability_base/interfaces/inner_api/base/include", + "//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler/include", + "//foundation/aafwk/standard/services/abilitymgr/include", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include", + "//foundation/arkui/napi/interfaces/kits/napi", + "//base/miscservices/time/utils/mock/include", + + "//base/miscservices/time/interfaces/innerkits/include", + "//utils/native/include", + "//base/miscservices/time/services/time_manager/include", + "//base/miscservices/time/services/timer/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", + "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/rdb/include/", + "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/appdatafwk/include/", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "timeservice_fuzzer.cpp" ] + + deps = [ + "//base/miscservices/time/interfaces/innerkits:time_client", + "//base/miscservices/time/services:time_service", + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core:appexecfwk_core", + "//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient:net_conn_manager_if", + "//third_party/jsoncpp:jsoncpp", + "//utils/native/base:utils", + ] + + external_deps = [ + "ability_base:want", + "ability_runtime:runtime", + "ability_runtime:wantagent_innerkits", + "common_event_service:cesfwk_innerkits", + "dataability:native_dataability", + "eventhandler:libeventhandler", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "relational_store:native_appdatafwk", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":TimeServiceFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/timeservice_fuzzer/corpus/init b/test/fuzztest/timeservice_fuzzer/corpus/init new file mode 100644 index 00000000..6b7212c8 --- /dev/null +++ b/test/fuzztest/timeservice_fuzzer/corpus/init @@ -0,0 +1 @@ +FUZZ \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/project.xml new file mode 100644 index 00000000..85e7ef2c --- /dev/null +++ b/test/fuzztest/timeservice_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp new file mode 100644 index 00000000..94d7a00f --- /dev/null +++ b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "timeservice_fuzzer.h" + +#include +#include + +#include "time_service.h" +#include "message_parcel.h" + +using namespace OHOS::MiscServices; + +namespace OHOS { +constexpr size_t THRESHOLD = 10; +constexpr int32_t OFFSET = 4; +const std::u16string TIMESERVICE_INTERFACE_TOKEN = u"ohos.miscseervice.screenlock"; + +uint32_t ConvertToUint32(const uint8_t* ptr) +{ + if (ptr == nullptr) { + return 0; + } + uint32_t bigvar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); + return bigvar; +} + +bool FuzzTimeService(const uint8_t* rawData, size_t size) +{ + uint32_t code = ConvertToUint32(rawData); + rawData = rawData + OFFSET; + size = size - OFFSET; + + MessageParcel data; + data.WriteInterfaceToken(TIMESERVICE_INTERFACE_TOKEN); + data.WriteBuffer(rawData, size); + data.RewindRead(0); + MessageParcel reply; + MessageOption option; + + sptr mTimess = new TimeService(); + mTimess->OnRemoteRequest(code, data, reply, option); + + return true; +} +} +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + if (size < OHOS::THRESHOLD) { + return -1; + } + /* Run your code on data */ + OHOS::FuzzTimeService(data, size); + return 0; +} + diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h new file mode 100644 index 00000000..b192035f --- /dev/null +++ b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H +#define TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H + +#define FUZZ_PROJECT_NAME "timeservice_fuzzer" + +#endif // TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file -- Gitee From aa0152fdf941b622fece53f5a5cb4f74e01a9896 Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:09:46 +0000 Subject: [PATCH 07/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20bu?= =?UTF-8?q?ndle.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundle.json | 77 ----------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 bundle.json diff --git a/bundle.json b/bundle.json deleted file mode 100644 index e578a5a4..00000000 --- a/bundle.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@ohos/time", - "description": "Allowing apps to use OS time get/set functions", - "version": "3.1", - "license": "Apache License 2.0", - "publishAs": "code-segment", - "segment": { - "destPath": "base/miscservices/time" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "time_native", - "subsystem": "miscservices", - "syscap": [ - "SystemCapability.MiscServices.Time" - ], - "features": [ - ], - "adapted_system_type": [ - "standard" - ], - "rom":"300KB", - "ram":"1024KB", - "deps": { - "components": [ - "ability_manager", - "aafwk_standard", - "appexecfwk_standard", - "ans_standard", - "common_event_service", - "hiviewdfx_hilog_native", - "distributeddatamgr", - "ipc", - "permission_standard", - "safwk", - "samgr_standard", - "startup_l2", - "utils_base" - ], - "third_party": [ - "jsoncpp" - ] - }, - "build": { - "sub_component": [ - "//base/miscservices/time:time_native_packages" - ], - "inner_kits": [ - { - "name": "//base/miscservices/time/services:time_service", - "header": { - "header_files": [ - "itimer_info.h", - "time_service_client.h" - ], - "header_base":"//base/miscservices/time/interfaces/innerkits/include" - } - }, - { - "name": "//base/miscservices/time/interfaces/innerkits:time_client", - "header": { - "header_files": [ - "itimer_info.h", - "time_service_client.h" - ], - "header_base":"//base/miscservices/time/interfaces/innerkits/include" - } - } - ], - "test": [ - "//base/miscservices/time/services/time_manager/test:TimeServiceTest", - "//base/miscservices/time/test/fuzztest:fuzztest" - ] - } - } -} -- Gitee From dfa1e5d6d4e88dbc1ba7e093f5b749384533b199 Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:10:14 +0000 Subject: [PATCH 08/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/BUILD.gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fuzztest/BUILD.gn | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 test/fuzztest/BUILD.gn diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn deleted file mode 100644 index 6b3cb58d..00000000 --- a/test/fuzztest/BUILD.gn +++ /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. - -import("//base/miscservices/time/time.gni") - -group("fuzztest") { - testonly = true - - deps = [ "timeservice_fuzzer:fuzztest" ] -} -- Gitee From 18f28c804fcc305ed8dccd054c0ed44d89ecd8b7 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Tue, 24 May 2022 17:10:54 +0800 Subject: [PATCH 09/14] Signed-off-by: lovechinamo Changes to be committed: --- bundle.json | 3 +- test/fuzztest/BUILD.gn | 20 ---- test/fuzztest/timeservice_fuzzer/BUILD.gn | 97 ------------------- test/fuzztest/timeservice_fuzzer/corpus/init | 1 - test/fuzztest/timeservice_fuzzer/project.xml | 25 ----- .../timeservice_fuzzer/timeservice_fuzzer.cpp | 69 ------------- .../timeservice_fuzzer/timeservice_fuzzer.h | 22 ----- 7 files changed, 1 insertion(+), 236 deletions(-) delete mode 100644 test/fuzztest/BUILD.gn delete mode 100644 test/fuzztest/timeservice_fuzzer/BUILD.gn delete mode 100644 test/fuzztest/timeservice_fuzzer/corpus/init delete mode 100644 test/fuzztest/timeservice_fuzzer/project.xml delete mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp delete mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h diff --git a/bundle.json b/bundle.json index e578a5a4..9073a4cd 100644 --- a/bundle.json +++ b/bundle.json @@ -69,8 +69,7 @@ } ], "test": [ - "//base/miscservices/time/services/time_manager/test:TimeServiceTest", - "//base/miscservices/time/test/fuzztest:fuzztest" + "//base/miscservices/time/services/time_manager/test:TimeServiceTest" ] } } diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn deleted file mode 100644 index 6b3cb58d..00000000 --- a/test/fuzztest/BUILD.gn +++ /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. - -import("//base/miscservices/time/time.gni") - -group("fuzztest") { - testonly = true - - deps = [ "timeservice_fuzzer:fuzztest" ] -} diff --git a/test/fuzztest/timeservice_fuzzer/BUILD.gn b/test/fuzztest/timeservice_fuzzer/BUILD.gn deleted file mode 100644 index 63c9c8df..00000000 --- a/test/fuzztest/timeservice_fuzzer/BUILD.gn +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -##############################fuzztest########################################## -ohos_fuzztest("TimeServiceFuzzTest") { - module_out_path = "miscservices/time" - - fuzz_config_file = "//base/miscservices/time/test/fuzztest/timeservice_fuzzer" - - include_dirs = [ - "//base/miscservices/time/services/time_manager/include", - "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - "//foundation/aafwk/standard/interfaces/innerkits/wantagent/include", - "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/configuration/include", - "//base/global/resource_management/interfaces/inner_api/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/want/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/uri/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/base/include", - "//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler/include", - "//foundation/aafwk/standard/services/abilitymgr/include", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include", - "//foundation/arkui/napi/interfaces/kits/napi", - "//base/miscservices/time/utils/mock/include", - - "//base/miscservices/time/interfaces/innerkits/include", - "//utils/native/include", - "//base/miscservices/time/services/time_manager/include", - "//base/miscservices/time/services/timer/include", - "//utils/system/safwk/native/include", - "//third_party/json/include", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/rdb/include/", - "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/appdatafwk/include/", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "timeservice_fuzzer.cpp" ] - - deps = [ - "//base/miscservices/time/interfaces/innerkits:time_client", - "//base/miscservices/time/services:time_service", - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core:appexecfwk_core", - "//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient:net_conn_manager_if", - "//third_party/jsoncpp:jsoncpp", - "//utils/native/base:utils", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:runtime", - "ability_runtime:wantagent_innerkits", - "common_event_service:cesfwk_innerkits", - "dataability:native_dataability", - "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "relational_store:native_appdatafwk", - "relational_store:native_rdb", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":TimeServiceFuzzTest", - ] -} -############################################################################### diff --git a/test/fuzztest/timeservice_fuzzer/corpus/init b/test/fuzztest/timeservice_fuzzer/corpus/init deleted file mode 100644 index 6b7212c8..00000000 --- a/test/fuzztest/timeservice_fuzzer/corpus/init +++ /dev/null @@ -1 +0,0 @@ -FUZZ \ No newline at end of file diff --git a/test/fuzztest/timeservice_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/project.xml deleted file mode 100644 index 85e7ef2c..00000000 --- a/test/fuzztest/timeservice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp deleted file mode 100644 index 94d7a00f..00000000 --- a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "timeservice_fuzzer.h" - -#include -#include - -#include "time_service.h" -#include "message_parcel.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 10; -constexpr int32_t OFFSET = 4; -const std::u16string TIMESERVICE_INTERFACE_TOKEN = u"ohos.miscseervice.screenlock"; - -uint32_t ConvertToUint32(const uint8_t* ptr) -{ - if (ptr == nullptr) { - return 0; - } - uint32_t bigvar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); - return bigvar; -} - -bool FuzzTimeService(const uint8_t* rawData, size_t size) -{ - uint32_t code = ConvertToUint32(rawData); - rawData = rawData + OFFSET; - size = size - OFFSET; - - MessageParcel data; - data.WriteInterfaceToken(TIMESERVICE_INTERFACE_TOKEN); - data.WriteBuffer(rawData, size); - data.RewindRead(0); - MessageParcel reply; - MessageOption option; - - sptr mTimess = new TimeService(); - mTimess->OnRemoteRequest(code, data, reply, option); - - return true; -} -} -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return -1; - } - /* Run your code on data */ - OHOS::FuzzTimeService(data, size); - return 0; -} - diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h deleted file mode 100644 index b192035f..00000000 --- a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timeservice_fuzzer" - -#endif // TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file -- Gitee From 8f40474256ea62247bf6d5a5aa6569c3c2b87f8c Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:13:07 +0000 Subject: [PATCH 10/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/timeservice=5Ffuzzer/BUILD.gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fuzztest/timeservice_fuzzer/BUILD.gn | 97 ----------------------- 1 file changed, 97 deletions(-) delete mode 100644 test/fuzztest/timeservice_fuzzer/BUILD.gn diff --git a/test/fuzztest/timeservice_fuzzer/BUILD.gn b/test/fuzztest/timeservice_fuzzer/BUILD.gn deleted file mode 100644 index 63c9c8df..00000000 --- a/test/fuzztest/timeservice_fuzzer/BUILD.gn +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -##############################fuzztest########################################## -ohos_fuzztest("TimeServiceFuzzTest") { - module_out_path = "miscservices/time" - - fuzz_config_file = "//base/miscservices/time/test/fuzztest/timeservice_fuzzer" - - include_dirs = [ - "//base/miscservices/time/services/time_manager/include", - "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - "//foundation/aafwk/standard/interfaces/innerkits/wantagent/include", - "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/configuration/include", - "//base/global/resource_management/interfaces/inner_api/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/want/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/uri/include", - "//foundation/aafwk/standard/ability_base/interfaces/inner_api/base/include", - "//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler/include", - "//foundation/aafwk/standard/services/abilitymgr/include", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include", - "//foundation/arkui/napi/interfaces/kits/napi", - "//base/miscservices/time/utils/mock/include", - - "//base/miscservices/time/interfaces/innerkits/include", - "//utils/native/include", - "//base/miscservices/time/services/time_manager/include", - "//base/miscservices/time/services/timer/include", - "//utils/system/safwk/native/include", - "//third_party/json/include", - "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", - "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/rdb/include/", - "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/appdatafwk/include/", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "timeservice_fuzzer.cpp" ] - - deps = [ - "//base/miscservices/time/interfaces/innerkits:time_client", - "//base/miscservices/time/services:time_service", - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core:appexecfwk_core", - "//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient:net_conn_manager_if", - "//third_party/jsoncpp:jsoncpp", - "//utils/native/base:utils", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:runtime", - "ability_runtime:wantagent_innerkits", - "common_event_service:cesfwk_innerkits", - "dataability:native_dataability", - "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "relational_store:native_appdatafwk", - "relational_store:native_rdb", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [] - deps += [ - # deps file - ":TimeServiceFuzzTest", - ] -} -############################################################################### -- Gitee From 9b914e8c829dab9509357c3e2f624c0e06521abd Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:13:21 +0000 Subject: [PATCH 11/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/timeservice=5Ffuzzer/corpus/init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fuzztest/timeservice_fuzzer/corpus/init | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/fuzztest/timeservice_fuzzer/corpus/init diff --git a/test/fuzztest/timeservice_fuzzer/corpus/init b/test/fuzztest/timeservice_fuzzer/corpus/init deleted file mode 100644 index 6b7212c8..00000000 --- a/test/fuzztest/timeservice_fuzzer/corpus/init +++ /dev/null @@ -1 +0,0 @@ -FUZZ \ No newline at end of file -- Gitee From 1ed5be4be9f7ee8d9d3d2d178d2f6b814426d5c0 Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:13:31 +0000 Subject: [PATCH 12/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/timeservice=5Ffuzzer/timeservice=5Ffuzzer.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeservice_fuzzer/timeservice_fuzzer.h | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h deleted file mode 100644 index b192035f..00000000 --- a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H -#define TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "timeservice_fuzzer" - -#endif // TEST_FUZZTEST_TIMESERVICE_FUZZER_TIMESERVICE_FUZZER_H \ No newline at end of file -- Gitee From d1c966dd25db4098ae49fa3294a60f7ae0658eba Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:13:43 +0000 Subject: [PATCH 13/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/timeservice=5Ffuzzer/project.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/fuzztest/timeservice_fuzzer/project.xml | 25 -------------------- 1 file changed, 25 deletions(-) delete mode 100644 test/fuzztest/timeservice_fuzzer/project.xml diff --git a/test/fuzztest/timeservice_fuzzer/project.xml b/test/fuzztest/timeservice_fuzzer/project.xml deleted file mode 100644 index 85e7ef2c..00000000 --- a/test/fuzztest/timeservice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - -- Gitee From c4acf5207ae73576759e73681be5ca323531fbbf Mon Sep 17 00:00:00 2001 From: wangdongqi Date: Tue, 24 May 2022 09:13:53 +0000 Subject: [PATCH 14/14] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20te?= =?UTF-8?q?st/fuzztest/timeservice=5Ffuzzer/timeservice=5Ffuzzer.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timeservice_fuzzer/timeservice_fuzzer.cpp | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp diff --git a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp b/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp deleted file mode 100644 index 94d7a00f..00000000 --- a/test/fuzztest/timeservice_fuzzer/timeservice_fuzzer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 "timeservice_fuzzer.h" - -#include -#include - -#include "time_service.h" -#include "message_parcel.h" - -using namespace OHOS::MiscServices; - -namespace OHOS { -constexpr size_t THRESHOLD = 10; -constexpr int32_t OFFSET = 4; -const std::u16string TIMESERVICE_INTERFACE_TOKEN = u"ohos.miscseervice.screenlock"; - -uint32_t ConvertToUint32(const uint8_t* ptr) -{ - if (ptr == nullptr) { - return 0; - } - uint32_t bigvar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]); - return bigvar; -} - -bool FuzzTimeService(const uint8_t* rawData, size_t size) -{ - uint32_t code = ConvertToUint32(rawData); - rawData = rawData + OFFSET; - size = size - OFFSET; - - MessageParcel data; - data.WriteInterfaceToken(TIMESERVICE_INTERFACE_TOKEN); - data.WriteBuffer(rawData, size); - data.RewindRead(0); - MessageParcel reply; - MessageOption option; - - sptr mTimess = new TimeService(); - mTimess->OnRemoteRequest(code, data, reply, option); - - return true; -} -} -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - if (size < OHOS::THRESHOLD) { - return -1; - } - /* Run your code on data */ - OHOS::FuzzTimeService(data, size); - return 0; -} - -- Gitee