!200 修复静态告警

Merge pull request !200 from shilei91/master
This commit is contained in:
openharmony_ci
2022-09-24 07:34:28 +00:00
committed by Gitee
5 changed files with 20 additions and 18 deletions
@@ -172,7 +172,7 @@ static uint8_t DeserializeInnerBundleName(IOwner owner, IpcIo *reply)
info->resultCode = ERR_APPEXECFWK_DESERIALIZATION_FAILED;
return ERR_APPEXECFWK_DESERIALIZATION_FAILED;
}
if (length < 0 || length > MAX_BUNDLE_NAME) {
if (length > MAX_BUNDLE_NAME) {
info->resultCode = ERR_APPEXECFWK_DESERIALIZATION_FAILED;
return ERR_APPEXECFWK_DESERIALIZATION_FAILED;
}
@@ -330,13 +330,10 @@ bool BundleInstaller::MatchPermissions(const std::vector<std::string> & restrict
int32_t size = realRestrictedPermissions.size();
for (int32_t i = 0; i < size; i++) {
bool isMatched = false;
for (const auto & restrictedPermission : restrictedPermissions) {
if (realRestrictedPermissions[i] == restrictedPermission) {
isMatched = true;
break;
}
}
bool isMatched = std::any_of(restrictedPermissions.begin(), restrictedPermissions.end(),
[realRestrictedPermissions, i](const auto & restrictedPermission)->bool {
return realRestrictedPermissions[i] == restrictedPermission;
});
if (!isMatched) {
HILOG_WARN(HILOG_MODULE_APP, "provisionPermissions is not match the bundle reqPermissions!");
return false;
@@ -109,7 +109,7 @@ char *GtBundleExtractor::ExtractHapProfile(int32_t fp, uint32_t totalFileSize)
}
int32_t fileNameLen = strlen(fileName);
if (pathLen == 0 && (fileName != nullptr && strcmp(fileName, PROFILE_NAME) == 0)) {
if (pathLen == 0 && (strcmp(fileName, PROFILE_NAME) == 0)) {
UI_Free(fileName);
fileName = nullptr;
fileData = reinterpret_cast<char *>(AdapterMalloc(fileSize * sizeof(char)));
@@ -109,8 +109,7 @@ uint8_t GtBundleInstaller::VerifySignature(const char *path, SignatureInfo &sign
VerifyResult verifyResult;
// verify signature
(void) APPVERI_SetDebugMode(true);
int32_t ret = (bundleStyle == THIRD_APP_FLAG) ? APPVERI_AppVerify(path, &verifyResult) :
APPVERI_AppVerify(path, &verifyResult);
int32_t ret = APPVERI_AppVerify(path, &verifyResult);
HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] APPVERI_AppVerify is %d", ret);
uint8_t errorCode = SwitchErrorCode(ret);
if (errorCode != ERR_OK) {
@@ -523,9 +522,6 @@ uint8_t GtBundleInstaller::UpdateBundleInfo(uint8_t bundleStyle, uint32_t labelI
if (bundleStyle == SYSTEM_APP_FLAG) {
bundleInfo->isSystemApp = true;
GtManagerService::GetInstance().AddBundleInfo(bundleInfo);
} else if (bundleStyle == THIRD_SYSTEM_APP_FLAG) {
bundleInfo->isSystemApp = false;
GtManagerService::GetInstance().AddBundleInfo(bundleInfo);
} else {
bundleInfo->isSystemApp = false;
GtManagerService::GetInstance().AddBundleInfo(bundleInfo);
@@ -414,10 +414,12 @@ void GtManagerService::RemoveSystemAppPathList(List<ToBeInstalledApp *> *systemP
for (auto node = systemPathList->Begin(); node != systemPathList->End(); node = node->next_) {
ToBeInstalledApp *toBeInstalledApp = node->value_;
AdapterFree(toBeInstalledApp->installedPath);
AdapterFree(toBeInstalledApp->path);
AdapterFree(toBeInstalledApp->appId);
UI_Free(toBeInstalledApp);
if (toBeInstalledApp != nullptr) {
AdapterFree(toBeInstalledApp->installedPath);
AdapterFree(toBeInstalledApp->path);
AdapterFree(toBeInstalledApp->appId);
UI_Free(toBeInstalledApp);
}
}
}
@@ -702,6 +704,9 @@ void GtManagerService::RemoveBundleResList(const char *bundleName)
for (auto node = bundleResList_->Begin(); node != bundleResList_->End(); node = node->next_) {
BundleRes *res = node->value_;
if (res == nullptr) {
return;
}
if (res->bundleName != nullptr && strcmp(bundleName, res->bundleName) == 0) {
AdapterFree(res->abilityRes);
AdapterFree(res);
@@ -1003,6 +1008,9 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list)
return;
}
char *fileName = reinterpret_cast<char *>(AdapterMalloc(MAX_NAME_LEN + 1));
if (fileName == nullptr) {
return;
}
while ((ent = readdir(dir)) != nullptr) {
if (memset_s(fileName, MAX_NAME_LEN + 1, 0, MAX_NAME_LEN + 1) != EOK) {
break;
@@ -1035,6 +1043,7 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list)
APP_InsertAppInfo(appPath, (AppInfoList *)&list->appDoubleList);
AdapterFree(appPath);
}
closedir(dir);
AdapterFree(fileName);
}