diff --git a/frameworks/osaccount/core/src/os_account_proxy.cpp b/frameworks/osaccount/core/src/os_account_proxy.cpp index 07ccdc2844b8c314c9d70a50aeebd803d848a735..cd0b58a0ebdb095fe7dc8a35286dfaef7578b756 100644 --- a/frameworks/osaccount/core/src/os_account_proxy.cpp +++ b/frameworks/osaccount/core/src/os_account_proxy.cpp @@ -434,7 +434,7 @@ ErrCode OsAccountProxy::QueryMaxOsAccountNumber(uint32_t &maxOsAccountNumber) ACCOUNT_LOGE("failed to read reply for query os account number, result %{public}d.", result); return result; } - maxOsAccountNumber = reply.ReadInt32(); + maxOsAccountNumber = static_cast(reply.ReadInt32()); return ERR_OK; } diff --git a/interfaces/innerkits/common/include/iaccount_info.h b/interfaces/innerkits/common/include/iaccount_info.h index 5d5c7dfc62c40c50390cc90c176674d31207e6d7..3289d7721fadd0cfb7b0a0c1111ceead6bc48498 100644 --- a/interfaces/innerkits/common/include/iaccount_info.h +++ b/interfaces/innerkits/common/include/iaccount_info.h @@ -56,7 +56,7 @@ void GetDataByType(const Json &jsonObject, const nlohmann::detail::iter_impl(); + data = static_cast(jsonObject.at(key).get()); break; case JsonType::OBJECT: if (!jsonObject.at(key).is_object()) { diff --git a/interfaces/kits/napi/account_iam/BUILD.gn b/interfaces/kits/napi/account_iam/BUILD.gn index 63c4d3fadbe099a5c169730ca59d92958a3aa1e1..74857718a706cf9efbc599ade1a687b2a98fd9ca 100644 --- a/interfaces/kits/napi/account_iam/BUILD.gn +++ b/interfaces/kits/napi/account_iam/BUILD.gn @@ -32,14 +32,6 @@ config("account_iam_kit_config") { } ohos_shared_library("account_iam_napi") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - configs = [ ":account_iam_kit_config", "${account_coverage_config_path}:coverage_flags", diff --git a/interfaces/kits/napi/appaccount/BUILD.gn b/interfaces/kits/napi/appaccount/BUILD.gn index 5c7ded0b7f49805c6a669927d00b9a3e5b9a6bbb..263cb8f60f75b3528be171faaa26e8b4a1646ac5 100644 --- a/interfaces/kits/napi/appaccount/BUILD.gn +++ b/interfaces/kits/napi/appaccount/BUILD.gn @@ -36,14 +36,6 @@ config("appaccount_kit_config") { } ohos_shared_library("appaccount") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - include_dirs = [] if (!use_clang_coverage) { version_script = "libappaccount.map" diff --git a/interfaces/kits/napi/common/BUILD.gn b/interfaces/kits/napi/common/BUILD.gn index 7a6448ae8695e96e5023b1bc9d752957478cc2db..184a0d35ffe42269ee6cb662668f6210ff4ce151 100644 --- a/interfaces/kits/napi/common/BUILD.gn +++ b/interfaces/kits/napi/common/BUILD.gn @@ -34,14 +34,6 @@ config("account_napi_common_config") { } ohos_shared_library("account_napi_common") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - include_dirs = [] configs = [ ":account_napi_common_config" ] public_configs = [ ":account_napi_common_config" ] diff --git a/interfaces/kits/napi/distributedaccount/BUILD.gn b/interfaces/kits/napi/distributedaccount/BUILD.gn index 7597058238950a49bf84009b21fbeebdc6fd9867..8c33a7ccc4a4732737099c22e31c2aa157cfc23e 100644 --- a/interfaces/kits/napi/distributedaccount/BUILD.gn +++ b/interfaces/kits/napi/distributedaccount/BUILD.gn @@ -15,14 +15,6 @@ import("//build/ohos.gni") import("../../../../os_account.gni") ohos_shared_library("distributedaccount") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - include_dirs = [ "include", "${os_account_path}/interfaces/innerkits/ohosaccount/native/include", diff --git a/interfaces/kits/napi/domain_account/BUILD.gn b/interfaces/kits/napi/domain_account/BUILD.gn index fcf5f1db62bf134810239e169c6d4f5a3f8a1f0d..9ae64684cb566ca46af5fa63972cbc4be89e7028 100644 --- a/interfaces/kits/napi/domain_account/BUILD.gn +++ b/interfaces/kits/napi/domain_account/BUILD.gn @@ -34,14 +34,6 @@ config("domain_account_napi_kit_config") { } ohos_shared_library("domain_account_napi") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - include_dirs = [] configs = [ ":domain_account_napi_kit_config" ] diff --git a/interfaces/kits/napi/domain_account/src/napi_domain_account_manager.cpp b/interfaces/kits/napi/domain_account/src/napi_domain_account_manager.cpp index 28d0fdb1e70084953163bdd8ad8197056307e6db..657fedfdb7cf484c3d4e655a1dc82605cac44a87 100644 --- a/interfaces/kits/napi/domain_account/src/napi_domain_account_manager.cpp +++ b/interfaces/kits/napi/domain_account/src/napi_domain_account_manager.cpp @@ -57,16 +57,15 @@ static bool InitDomainPluginExecEnv( return true; } -static napi_value CreatePluginAsyncCallback( - napi_env env, napi_callback callback, std::unique_ptr ¶m) +static napi_value CreatePluginAsyncCallback(napi_env env, napi_callback callback, JsDomainPluginParam *param) { napi_value napiCallback = nullptr; - napi_status status = napi_create_function(env, "callback", NAPI_AUTO_LENGTH, callback, param.get(), &napiCallback); + napi_status status = napi_create_function(env, "callback", NAPI_AUTO_LENGTH, callback, param, &napiCallback); if (status != napi_ok) { ACCOUNT_LOGE("failed to create js function"); return nullptr; } - status = napi_wrap(env, napiCallback, param.get(), + status = napi_wrap(env, napiCallback, param, [](napi_env env, void *data, void *hint) { ACCOUNT_LOGI("release JsDomainPluginParam"); delete reinterpret_cast(data); @@ -121,7 +120,7 @@ static napi_value CreateNapiDomainAccountInfo(napi_env env, const DomainAccountI return napiInfo; } -static napi_value CreateNapiGetAccessTokenOptions(const std::unique_ptr ¶m) +static napi_value CreateNapiGetAccessTokenOptions(const JsDomainPluginParam *param) { napi_value napiOptions = nullptr; NAPI_CALL(param->env, napi_create_object(param->env, &napiOptions)); @@ -302,7 +301,7 @@ static napi_value GetDomainAccountInfoCallback(napi_env env, napi_callback_info return nullptr; } -static napi_value CreatePluginAccountInfoOptions(const std::unique_ptr ¶m) +static napi_value CreatePluginAccountInfoOptions(const JsDomainPluginParam *param) { napi_value napiOptions = nullptr; NAPI_CALL(param->env, napi_create_object(param->env, &napiOptions)); @@ -327,7 +326,7 @@ static void GetDomainAccountInfoWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiCallback = CreatePluginAsyncCallback(param->env, GetDomainAccountInfoCallback, param); napi_value getDomainAccountInfoPLuginOptions = CreatePluginAccountInfoOptions(param); napi_value argv[] = {getDomainAccountInfoPLuginOptions, napiCallback}; @@ -336,6 +335,7 @@ static void GetDomainAccountInfoWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } static napi_value OnAccountBoundCallback(napi_env env, napi_callback_info cbInfo) @@ -369,7 +369,7 @@ static void OnAccountBoundWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiLocalId = nullptr; napi_create_int32(param->env, param->userId, &napiLocalId); napi_value napiDomainAccountInfo = CreateNapiDomainAccountInfo(param->env, param->domainAccountInfo); @@ -380,6 +380,7 @@ static void OnAccountBoundWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } static void OnAccountUnBoundWork(uv_work_t *work, int status) @@ -389,7 +390,7 @@ static void OnAccountUnBoundWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiDomainAccountInfo = CreateNapiDomainAccountInfo(param->env, param->domainAccountInfo); napi_value napiCallback = CreatePluginAsyncCallback(param->env, OnAccountBoundCallback, param); napi_value argv[] = {napiDomainAccountInfo, napiCallback}; @@ -398,6 +399,7 @@ static void OnAccountUnBoundWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } static napi_value GetAuthStatusInfoCallback(napi_env env, napi_callback_info cbInfo) @@ -485,7 +487,7 @@ static void GetAccessTokenWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiCallback = CreatePluginAsyncCallback(param->env, GetAccessTokenCallback, param); napi_value napiOptions = CreateNapiGetAccessTokenOptions(param); napi_value argv[] = {napiOptions, napiCallback}; @@ -494,6 +496,7 @@ static void GetAccessTokenWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } static void IsUserTokenValidWork(uv_work_t *work, int status) @@ -503,7 +506,7 @@ static void IsUserTokenValidWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiCallback = CreatePluginAsyncCallback(param->env, IsUserTokenValidCallback, param); napi_value napiDomainAccountInfo = CreateNapiDomainAccountInfo(param->env, param->domainAccountInfo); napi_value napiUserToken = CreateUint8Array(param->env, param->authData.data(), param->authData.size()); @@ -513,6 +516,7 @@ static void IsUserTokenValidWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } static void GetAuthStatusInfoWork(uv_work_t *work, int status) @@ -522,7 +526,7 @@ static void GetAuthStatusInfoWork(uv_work_t *work, int status) if (!InitUvWorkCallbackEnv(work, scope)) { return; } - std::unique_ptr param(reinterpret_cast(work->data)); + JsDomainPluginParam *param = reinterpret_cast(work->data); napi_value napiDomainAccountInfo = CreateNapiDomainAccountInfo(param->env, param->domainAccountInfo); napi_value napiCallback = CreatePluginAsyncCallback(param->env, GetAuthStatusInfoCallback, param); napi_value argv[] = {napiDomainAccountInfo, napiCallback}; @@ -531,6 +535,7 @@ static void GetAuthStatusInfoWork(uv_work_t *work, int status) param->lockInfo->count--; param->lockInfo->condition.notify_all(); napi_close_handle_scope(param->env, scope); + delete param; } NapiDomainAccountPlugin::NapiDomainAccountPlugin(napi_env env, const JsDomainPlugin &jsPlugin) diff --git a/interfaces/kits/napi/osaccount/BUILD.gn b/interfaces/kits/napi/osaccount/BUILD.gn index 11a61967f956cf188f05feb0541bed538471322e..5f0578ae4a8771bffecae96bdd5d1850e8323648 100644 --- a/interfaces/kits/napi/osaccount/BUILD.gn +++ b/interfaces/kits/napi/osaccount/BUILD.gn @@ -37,14 +37,6 @@ config("osaccount_kit_config") { } ohos_shared_library("osaccount") { - branch_protector_ret = "pac_ret" - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - configs = [ ":osaccount_kit_config", "${account_coverage_config_path}:coverage_flags", diff --git a/services/accountmgr/src/account_file_watcher_manager.cpp b/services/accountmgr/src/account_file_watcher_manager.cpp index cc8d463342c67100642b5985e897cec9deb373bb..de5fb9266fda6b064dfd298a7a25a578a2739d9c 100644 --- a/services/accountmgr/src/account_file_watcher_manager.cpp +++ b/services/accountmgr/src/account_file_watcher_manager.cpp @@ -241,7 +241,7 @@ void AccountFileWatcherMgr::DealWithFileEvent() char buf[BUF_COMMON_SIZE] = {0}; struct inotify_event *event = nullptr; int len = 0; - uint32_t index = 0; + int index = 0; while (((len = read(inotifyFd_, &buf, sizeof(buf))) < 0) && (errno == EINTR)) {}; while (index < len) { event = reinterpret_cast(buf + index); @@ -251,7 +251,7 @@ void AccountFileWatcherMgr::DealWithFileEvent() eventMap.emplace_back(std::make_pair(fileWatcher, event->mask)); } } - index += sizeof(struct inotify_event) + event->len; + index += static_cast(sizeof(struct inotify_event) + event->len); } } for (auto it : eventMap) { diff --git a/services/accountmgr/src/appaccount/app_account_manager_service.cpp b/services/accountmgr/src/appaccount/app_account_manager_service.cpp index 784a661f9eadb89bd8b936710c1f7768ed7171f5..b9eef931505147587d63fa5b608521bd7c259edd 100644 --- a/services/accountmgr/src/appaccount/app_account_manager_service.cpp +++ b/services/accountmgr/src/appaccount/app_account_manager_service.cpp @@ -789,7 +789,7 @@ ErrCode AppAccountManagerService::GetCallingTokenInfoAndAppIndex(uint32_t &appIn ACCOUNT_LOGE("get invalid app index from hap token info, index = %{public}d", hapTokenInfo.instIndex); return ERR_APPACCOUNT_SERVICE_GET_APP_INDEX; } - appIndex = hapTokenInfo.instIndex; + appIndex = static_cast(hapTokenInfo.instIndex); return ERR_OK; } diff --git a/services/accountmgr/src/domain_account/domain_account_stub.cpp b/services/accountmgr/src/domain_account/domain_account_stub.cpp index f35662e99712272cbfb7ff6e2b00195127ad8576..85884cf7575170f25619e9a180c5f22dbcb28880 100644 --- a/services/accountmgr/src/domain_account/domain_account_stub.cpp +++ b/services/accountmgr/src/domain_account/domain_account_stub.cpp @@ -220,6 +220,10 @@ ErrCode DomainAccountStub::ProcSetAuthenticationExpiryThreshold(MessageParcel &d ErrCode DomainAccountStub::ProcRegisterPlugin(MessageParcel &data, MessageParcel &reply) { auto plugin = iface_cast(data.ReadRemoteObject()); + if (plugin == nullptr) { + ACCOUNT_LOGE("Failed to read plugin"); + return IPC_STUB_WRITE_PARCEL_ERR; + } ErrCode result = RegisterPlugin(plugin); if (!reply.WriteInt32(result)) { ACCOUNT_LOGE("failed to write result"); diff --git a/services/accountmgr/src/domain_account/inner_domain_account_manager.cpp b/services/accountmgr/src/domain_account/inner_domain_account_manager.cpp index cb311d8d152e3acb6caa5f07bbaf6ba266e26263..12258fbbb8f33a5e0cfc36558cb59f8280fc246b 100644 --- a/services/accountmgr/src/domain_account/inner_domain_account_manager.cpp +++ b/services/accountmgr/src/domain_account/inner_domain_account_manager.cpp @@ -502,12 +502,12 @@ ErrCode InnerDomainAccountManager::AddServerConfig(const std::string &paremters, ACCOUNT_LOGE("Caller method=%{public}d not exsit.", PluginMethodEnum::ADD_SERVER_CONFIG); return ConvertToJSErrCode(ERR_DOMAIN_ACCOUNT_SERVICE_PLUGIN_NOT_EXIST); } - PluginString param; - SetPluginString(paremters, param); int32_t localId = GetCallingUserID(); if (localId == -1) { return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR; } + PluginString param; + SetPluginString(paremters, param); PluginServerConfigInfo *configInfo = nullptr; PluginBussnessError* error = (*reinterpret_cast(iter->second))(¶m, localId, &configInfo); GetAndCleanPluginServerConfigInfo(&configInfo, config.id_, config.domain_, config.parameters_); @@ -523,12 +523,12 @@ ErrCode InnerDomainAccountManager::RemoveServerConfig(const std::string &configI ACCOUNT_LOGE("Caller method=%{public}d not exsit.", PluginMethodEnum::REMOVE_SERVER_CONFIG); return ConvertToJSErrCode(ERR_DOMAIN_ACCOUNT_SERVICE_PLUGIN_NOT_EXIST); } - PluginString serverConfigId; - SetPluginString(configId, serverConfigId); int32_t localId = GetCallingUserID(); if (localId == -1) { return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR; } + PluginString serverConfigId; + SetPluginString(configId, serverConfigId); PluginBussnessError* error = (*reinterpret_cast(iter->second))(&serverConfigId, localId); CleanPluginString(&(serverConfigId.data), serverConfigId.length); return GetAndCleanPluginBussnessError(&error, iter->first); @@ -564,13 +564,13 @@ ErrCode InnerDomainAccountManager::PluginAuth(const DomainAccountInfo &info, con ACCOUNT_LOGE("Caller method=%{public}d not exsit.", PluginMethodEnum::AUTH); return ConvertToJSErrCode(ERR_DOMAIN_ACCOUNT_SERVICE_PLUGIN_NOT_EXIST); } - PluginDomainAccountInfo domainAccountInfo; - SetPluginDomainAccountInfo(info, domainAccountInfo); int32_t localId = GetCallingUserID(); if (localId == -1) { ACCOUNT_LOGE("fail to get activated os account ids"); return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR; } + PluginDomainAccountInfo domainAccountInfo; + SetPluginDomainAccountInfo(info, domainAccountInfo); PluginUint8Vector credential; SetPluginUint8Vector(password, credential); PluginAuthResultInfo *authResultInfo = nullptr; @@ -630,14 +630,14 @@ ErrCode InnerDomainAccountManager::PluginBindAccount(const DomainAccountInfo &in ACCOUNT_LOGE("Caller method=%{public}d not exsit.", PluginMethodEnum::BIND_ACCOUNT); return ConvertToJSErrCode(ERR_DOMAIN_ACCOUNT_SERVICE_PLUGIN_NOT_EXIST); } - PluginDomainAccountInfo domainAccountInfo; - SetPluginDomainAccountInfo(info, domainAccountInfo); ACCOUNT_LOGD("Param localId=%{public}d.", localId); int32_t callerLocalId = GetCallingUserID(); if (localId == -1) { ACCOUNT_LOGE("fail to get activated os account ids"); return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR; } + PluginDomainAccountInfo domainAccountInfo; + SetPluginDomainAccountInfo(info, domainAccountInfo); PluginBussnessError* error = (*reinterpret_cast(iter->second))(&domainAccountInfo, localId, callerLocalId); CleanPluginString(&(domainAccountInfo.domain.data), domainAccountInfo.domain.length);