diff --git a/services/distributeddataservice/service/data_share/common/kv_delegate.cpp b/services/distributeddataservice/service/data_share/common/kv_delegate.cpp index 1c2375d436fc28151aa10bed469093ab6922e147..d9f4d194c0a7f093cd4088eb2aeb298c64459ebb 100644 --- a/services/distributeddataservice/service/data_share/common/kv_delegate.cpp +++ b/services/distributeddataservice/service/data_share/common/kv_delegate.cpp @@ -282,7 +282,7 @@ std::pair KvDelegate::Upsert(const std::string &collectionName int version = -1; if (GetVersion(collectionName, id, version)) { if (value.GetVersion() <= version) { - ZLOGE("GetVersion failed,%{public}s id %{private}s %{public}d %{public}d", collectionName.c_str(), + ZLOGE("GetVersion failed,%{public}s id %{public}s %{public}d %{public}d", collectionName.c_str(), id.c_str(), value.GetVersion(), version); return std::make_pair(E_VERSION_NOT_NEWER, 0); } diff --git a/services/distributeddataservice/service/data_share/common/proxy_data_manager.cpp b/services/distributeddataservice/service/data_share/common/proxy_data_manager.cpp index 18a7b53638bba26d8af0210612673f6166ae8932..8a9988e0c401e94e7e8333b63500074246cc894a 100644 --- a/services/distributeddataservice/service/data_share/common/proxy_data_manager.cpp +++ b/services/distributeddataservice/service/data_share/common/proxy_data_manager.cpp @@ -337,7 +337,7 @@ int32_t PublishedProxyData::Delete(const std::string &uri, const BundleInfo &cal ProxyDataNode oldData; if (!ProxyDataNode::Unmarshall(queryResult, oldData)) { - ZLOGE("Unmarshall failed, %{private}s", queryResult.c_str()); + ZLOGE("Unmarshall failed, %{public}s", StringUtils::GeneralAnonymous(queryResult).c_str()); return INNER_ERROR; } if (callerBundleInfo.tokenId != oldData.tokenId) { diff --git a/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp b/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp index 940f599c448413ab291344275d46ff19207f4951..2edad984d468c517a0ede1053320ece226cfc9e4 100644 --- a/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp +++ b/services/distributeddataservice/service/data_share/common/rdb_delegate.cpp @@ -31,6 +31,7 @@ #include "scheduler_manager.h" #include "string_wrapper.h" #include "utils/anonymous.h" +#include "utils.h" #include "want_params.h" #include "db_delegate.h" #include "log_debug.h" @@ -298,7 +299,7 @@ std::string RdbDelegate::Query(const std::string &sql, const std::vectorQueryByStep(sql, selectionArgs); if (resultSet == nullptr) { - ZLOGE("Query failed %{private}s", sql.c_str()); + ZLOGE("Query failed %{public}s", StringUtils::GeneralAnonymous(sql).c_str()); return ""; } int rowCount; @@ -318,7 +319,7 @@ std::shared_ptr RdbDelegate::QuerySql(const std::string &s } auto resultSet = store_->QuerySql(sql); if (resultSet == nullptr) { - ZLOGE("Query failed %{private}s", sql.c_str()); + ZLOGE("Query failed %{public}s", StringUtils::GeneralAnonymous(sql).c_str()); return resultSet; } int rowCount; @@ -375,4 +376,4 @@ bool RdbDelegate::IsLimit(int count, int32_t callingPid, uint32_t callingTokenId HiViewFaultAdapter::ReportDataFault(faultInfo); return true; } -} // namespace OHOS::DataShare \ No newline at end of file +} // namespace OHOS::DataShare diff --git a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp index fa7ec6a969581674ccc00a3ed10535173db59c8d..d8a87a67db954a61d92b3825f7e60b3f74f67627 100644 --- a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp +++ b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp @@ -209,14 +209,14 @@ void SchedulerManager::SetTimer( duration, key.subscriberId, key.bundleName.c_str()); auto it = timerCache_.find(key); if (it != timerCache_.end()) { - ZLOGD_MACRO("has current taskId: %{private}s, subscriberId is %{public}" PRId64 ", bundleName is %{public}s", + ZLOGD_MACRO("has current taskId: %{public}s, subscriberId is %{public}" PRId64 ", bundleName is %{public}s", URIUtils::Anonymous(key.uri).c_str(), key.subscriberId, key.bundleName.c_str()); auto timerId = it->second; ResetTimerTask(timerId, reminderTime); return; } auto callback = [key, metaData, userId, this]() { - ZLOGI("schedule notify start, uri is %{private}s, subscriberId is %{public}" PRId64 ", bundleName is " + ZLOGI("schedule notify start, uri is %{public}s, subscriberId is %{public}" PRId64 ", bundleName is " "%{public}s", URIUtils::Anonymous(key.uri).c_str(), key.subscriberId, key.bundleName.c_str()); int64_t timerId = EraseTimerTaskId(key); diff --git a/services/distributeddataservice/service/data_share/data/template_data.cpp b/services/distributeddataservice/service/data_share/data/template_data.cpp index 79219aedefc4cb40bb85498c80b35a826049e236..af7bbb26ea18202f8f68a1fbcfd83b86942a7b78 100644 --- a/services/distributeddataservice/service/data_share/data/template_data.cpp +++ b/services/distributeddataservice/service/data_share/data/template_data.cpp @@ -15,6 +15,8 @@ #define LOG_TAG "TemplateData" #include "template_data.h" #include "log_print.h" +#include "utils.h" + namespace OHOS::DataShare { bool TemplateNode::Marshal(DistributedData::Serializable::json &node) const { @@ -121,7 +123,7 @@ int32_t TemplateData::Query(const std::string &filter, Template &aTemplate) } TemplateRootNode data; if (!DistributedData::Serializable::Unmarshall(queryResult, data)) { - ZLOGE("Unmarshall failed, %{private}s", queryResult.c_str()); + ZLOGE("Unmarshall failed, %{public}s", StringUtils::GeneralAnonymous(queryResult).c_str()); return E_ERROR; } aTemplate = data.ToTemplate(); @@ -207,4 +209,4 @@ bool PredicatesNode::Unmarshal(const DistributedData::Serializable::json &node) ret = ret && GetValue(node, GET_NAME(selectSql), selectSql); return ret; } -} // namespace OHOS::DataShare \ No newline at end of file +} // namespace OHOS::DataShare diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp index 75730097cd485b623cd26b114e29bc4693dd7e54..23a91bd71dab6b06bba070f64e38a80ce9446fcc 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp @@ -261,9 +261,9 @@ int32_t DataShareServiceImpl::AddTemplate(const std::string &uri, const int64_t ZLOGE("get bundleName error, %{public}s", URIUtils::Anonymous(uri).c_str()); return ERROR; } - ZLOGI("Add template, uri %{private}s, subscriberId %{public}" PRIi64 ", bundleName %{public}s," + ZLOGI("Add template, uri %{public}s, subscriberId %{public}" PRIi64 ", bundleName %{public}s," "predicates size %{public}zu.", - uri.c_str(), subscriberId, tpltId.bundleName_.c_str(), tplt.predicates_.size()); + URIUtils::Anonymous(uri).c_str(), subscriberId, tpltId.bundleName_.c_str(), tplt.predicates_.size()); return templateStrategy_.Execute(context, [&uri, &tpltId, &tplt, &context]() -> int32_t { auto result = TemplateManager::GetInstance().Add( Key(uri, tpltId.subscriberId_, tpltId.bundleName_), context->visitedUserId, tplt); @@ -281,7 +281,7 @@ int32_t DataShareServiceImpl::DelTemplate(const std::string &uri, const int64_t ZLOGE("get bundleName error, %{public}s", URIUtils::Anonymous(uri).c_str()); return ERROR; } - ZLOGI("Delete template, uri %{private}s, subscriberId %{public}" PRIi64 ", bundleName %{public}s.", + ZLOGI("Delete template, uri %{public}s, subscriberId %{public}" PRIi64 ", bundleName %{public}s.", URIUtils::Anonymous(uri).c_str(), subscriberId, tpltId.bundleName_.c_str()); return templateStrategy_.Execute(context, [&uri, &tpltId, &context]() -> int32_t { return TemplateManager::GetInstance().Delete( @@ -870,15 +870,15 @@ int32_t DataShareServiceImpl::OnAppUpdate(const std::string &bundleName, int32_t void DataShareServiceImpl::NotifyObserver(const std::string &uri) { auto anonymous = URIUtils::Anonymous(uri); - ZLOGD_MACRO("%{private}s try notified", anonymous.c_str()); + ZLOGD_MACRO("%{public}s try notified", anonymous.c_str()); auto context = std::make_shared(uri); if (!GetCallerBundleName(context->callerBundleName)) { - ZLOGE("get bundleName error, %{private}s", anonymous.c_str()); + ZLOGE("get bundleName error, %{public}s", anonymous.c_str()); return; } auto ret = rdbNotifyStrategy_.Execute(context); if (ret) { - ZLOGI("%{private}s start notified", anonymous.c_str()); + ZLOGI("%{public}s start notified", anonymous.c_str()); RdbSubscriberManager::GetInstance().Emit(uri, context); } } diff --git a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn index 22cb65f5eabc12299009aa89a9c72b7fd14d7bce..f26c4fb2b6471561b5f4d94e05735700aac79fff 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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 @@ -129,7 +129,6 @@ ohos_fuzztest("DataShareServiceImplFuzzTest") { "hilog:libhilog", "hisysevent:libhisysevent", "huks:libhukssdk", - "init:libbegetutil", "ipc:ipc_core", "kv_store:distributeddata_inner", "kv_store:distributeddb", diff --git a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/datashareserviceimpl_fuzzer.cpp b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/datashareserviceimpl_fuzzer.cpp index 83644b248371376d72cb6b254448f89af95edfc3..a61ead41633ff12b695bce18cd71d892e6736131 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/datashareserviceimpl_fuzzer.cpp +++ b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/datashareserviceimpl_fuzzer.cpp @@ -172,6 +172,8 @@ void TimerReceiverOnReceiveEventFuzz(FuzzedDataProvider &provider) { DataShareServiceImpl::TimerReceiver tmerReceiver; EventFwk::Want want; + std::string action = provider.ConsumeRandomLengthString(); + want.SetAction(action); EventFwk::CommonEventData commonEventData(want); commonEventData.SetWant(want); tmerReceiver.OnReceiveEvent(commonEventData); @@ -336,12 +338,6 @@ void SaveLaunchInfoFuzz(FuzzedDataProvider &provider) dataShareServiceImpl->SaveLaunchInfo(bundleName, userId, deviceId); } -void OnConnectDoneFuzz(FuzzedDataProvider &provider) -{ - std::shared_ptr dataShareServiceImpl = std::make_shared(); - dataShareServiceImpl->OnConnectDone(); -} - void DataShareStaticOnAppUpdate(FuzzedDataProvider &provider) { DataShareServiceImpl::DataShareStatic dataShareStatic; @@ -357,6 +353,7 @@ void EnableSilentProxyFuzz(FuzzedDataProvider &provider) std::string uri = provider.ConsumeRandomLengthString(); bool enable = provider.ConsumeBool(); dataShareServiceImpl->EnableSilentProxy(uri, enable); + dataShareServiceImpl->OnConnectDone(); } } // namespace OHOS @@ -392,7 +389,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) OHOS::SubscribePublishedDataFuzz(provider); OHOS::DisablePubSubsFuzz(provider); OHOS::SaveLaunchInfoFuzz(provider); - OHOS::OnConnectDoneFuzz(provider); OHOS::DataShareStaticOnAppUpdate(provider); OHOS::EnableSilentProxyFuzz(provider); return 0;