!1368 文件扫描加固

Merge pull request !1368 from chensihan/dirfix903
This commit is contained in:
openharmony_ci 2024-11-15 10:22:52 +00:00 committed by Gitee
commit 970ef7f989
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 7 deletions

View File

@ -860,8 +860,8 @@ void Service::HandleCurGroupBackupInfos(std::vector<BJsonEntityCaps::BundleInfo>
SetCurrentSessProperties(info, isClearDataFlags, bundleNameIndexInfo);
BJsonUtil::BundleDetailInfo uniCastInfo;
if (BJsonUtil::FindBundleInfoByName(bundleNameDetailMap, bundleNameIndexInfo, UNICAST_TYPE, uniCastInfo)) {
HILOGI("current bundle:%{public}s, unicast info:%{public}s", bundleNameIndexInfo.c_str(),
GetAnonyString(uniCastInfo.detail).c_str());
HILOGI("current bundle:%{public}s, unicast info:%{public}s, unicast info size:%{public}zu",
bundleNameIndexInfo.c_str(), GetAnonyString(uniCastInfo.detail).c_str(), uniCastInfo.detail.size());
session_->SetBackupExtInfo(bundleNameIndexInfo, uniCastInfo.detail);
}
session_->SetBackupExtName(bundleNameIndexInfo, info.extensionName);

View File

@ -65,7 +65,8 @@ static tuple<ErrCode, map<string, struct stat>, map<string, size_t>> GetFile(con
map<string, size_t> smallFiles;
struct stat sta = {};
if (stat(path.data(), &sta) == -1) {
return {BError(errno).GetCode(), files, smallFiles};
HILOGE("File not exist, errno:%{public}d, fileName:%{private}s.", errno, path.c_str());
return {BError(BError::Codes::OK).GetCode(), files, smallFiles};
}
if (path == "/") {
return {BError(BError::Codes::OK).GetCode(), files, smallFiles};
@ -268,11 +269,11 @@ tuple<ErrCode, map<string, struct stat>, map<string, size_t>> BDir::GetBigFiles(
map<string, struct stat> incFiles;
map<string, size_t> incSmallFiles;
for (const auto &item : inc) {
HILOGW("GetBigFiles, path = %{public}s", item.c_str());
auto [errCode, files, smallFiles] = GetDirFilesDetail(item, true, BConstants::BIG_FILE_BOUNDARY);
if (errCode == 0) {
int32_t num = static_cast<int32_t>(files.size());
incFiles.merge(move(files));
HILOGI("big files: %{public}d; small files: %{public}d", num, static_cast<int32_t>(smallFiles.size()));
HILOGW("big files: %{public}zu; small files: %{public}zu", files.size(), smallFiles.size());
incSmallFiles.insert(smallFiles.begin(), smallFiles.end());
}
}
@ -309,8 +310,8 @@ tuple<ErrCode, map<string, struct stat>, map<string, size_t>> BDir::GetBigFiles(
bigFiles[item.first] = item.second;
}
}
HILOGI("total number of big files is %{public}d", static_cast<int32_t>(bigFiles.size()));
HILOGI("total number of small files is %{public}d", static_cast<int32_t>(resSmallFiles.size()));
HILOGW("total number of big files is %{public}zu", bigFiles.size());
HILOGW("total number of small files is %{public}zu", resSmallFiles.size());
return {ERR_OK, move(bigFiles), move(resSmallFiles)};
}