diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 87b1cfda47483c7014681a2048df70ddc83ef0ff..ca44868071791e8a9e3f6cda902338b3bd84252d 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -199,7 +199,7 @@ static bool CreateIPCInteractionFiles(int32_t userId, const string &bundleName, bundleName + BConstants::FILE_SEPARATOR_CHAR; if (access(backupSaBundleDir.data(), F_OK) != 0) { int32_t err = mkdir(backupSaBundleDir.data(), S_IRWXU | S_IRWXG); - if (err != 0) { + if (err != 0 && errno != EEXIST) { HILOGE("Failed to create folder in backup_sa bundleName:%{public}s, sys err:%{public}d", bundleName.c_str(), errno); return false; diff --git a/utils/src/b_json/b_json_service_disposal_config.cpp b/utils/src/b_json/b_json_service_disposal_config.cpp index ca94e2112e32f880c6ddf073061c50918a7e043f..5ab1644b87c8f632a170c8a50d665da237ac14f8 100644 --- a/utils/src/b_json/b_json_service_disposal_config.cpp +++ b/utils/src/b_json/b_json_service_disposal_config.cpp @@ -93,13 +93,13 @@ bool BJsonDisposalConfig::AppendIntoDisposalConfigFile(const string& bundleName) } cJSON *configArray = cJSON_GetObjectItem(jsonObjectDis, "DispoasalConfigFile"); - if (configArray == nullptr) { + if (configArray == nullptr || !cJSON_IsArray(configArray)) { HILOGE("parse json failed"); cJSON_Delete(jsonObjectDis); return false; } cJSON *newItem = cJSON_CreateObject(); - if (configArray == nullptr || newItem == nullptr) { + if (newItem == nullptr) { HILOGE("parse json failed"); cJSON_Delete(jsonObjectDis); return false; @@ -148,7 +148,7 @@ bool BJsonDisposalConfig::DeleteFromDisposalConfigFile(const string& bundleName) } cJSON *configArray = cJSON_GetObjectItem(jsonObjectDis, "DispoasalConfigFile"); - if (configArray == nullptr) { + if (configArray == nullptr || !cJSON_IsArray(configArray)) { cJSON_Delete(jsonObjectDis); return false; } @@ -202,7 +202,7 @@ bool BJsonDisposalConfig::IfBundleNameInDisposalConfigFile(const string& bundleN } cJSON *configArray = cJSON_GetObjectItem(jsonObjectDis, "DispoasalConfigFile"); - if (configArray == nullptr) { + if (configArray == nullptr || !cJSON_IsArray(configArray)) { HILOGE("parse json failed"); cJSON_Delete(jsonObjectDis); return false; @@ -246,7 +246,7 @@ vector BJsonDisposalConfig::GetBundleNameFromConfigFile() } cJSON *configArray = cJSON_GetObjectItem(jsonObjectDis, "DispoasalConfigFile"); - if (configArray == nullptr) { + if (configArray == nullptr || !cJSON_IsArray(configArray)) { HILOGE("parse json failed"); cJSON_Delete(jsonObjectDis); return {};