已开启
Rectify sensitive information in logs #2266
dongtingchi创建于 17 天前
Rectify sensitive information in logs #2266
已开启
共 5 个文件变更+20-14
| @@ -688,9 +688,9 @@ ErrCode BackupExtExtension::ReportNormalAppFileReady(const string& filename, con | |||
| 688 | int fdval = open(newPath.data(), O_RDONLY | O_UNCACHE); | 688 | int fdval = open(newPath.data(), O_RDONLY | O_UNCACHE); |
| 689 | if (fdval < 0) { | 689 | if (fdval < 0) { |
| 690 | errCode = errno; | 690 | errCode = errno; |
| 691 | - HILOGE("open file failed, filename: %{public}s, err: %{public}d", GetAnonyString(filePath).c_str(), errCode); | 691 | + HILOGE("open file failed, filename: %{public}s, err: %{public}d", GetAnonyPath(filePath).c_str(), errCode); |
| 692 | if (errCode == ERR_NO_PERMISSION) { | 692 | if (errCode == ERR_NO_PERMISSION) { |
| 693 | - HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyString(filePath).c_str()); | 693 | + HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyPath(filePath).c_str()); |
| 694 | return errCode; | 694 | return errCode; |
| 695 | } | 695 | } |
| 696 | } | 696 | } |
| @@ -738,9 +738,10 @@ void BackupExtExtension::ProcessReadysInfo(std::vector<std::shared_ptr<IFileInfo | |||
| 738 | int fdval = open(newPath.data(), O_RDONLY | O_UNCACHE); | 738 | int fdval = open(newPath.data(), O_RDONLY | O_UNCACHE); |
| 739 | if (fdval < 0) { | 739 | if (fdval < 0) { |
| 740 | int errCode = errno; | 740 | int errCode = errno; |
| 741 | - HILOGE("open file failed, filename: %{public}s, err: %{public}d", filePath.c_str(), errCode); | 741 | + HILOGE("open file failed, filename: %{public}s, err: %{public}d", GetAnonyPath(filePath).c_str(), |
| 742 | + errCode); | ||
| 742 | if (errCode == ERR_NO_PERMISSION) { | 743 | if (errCode == ERR_NO_PERMISSION) { |
| 743 | - HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyString(filePath).c_str()); | 744 | + HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyPath(filePath).c_str()); |
| 744 | it = allFiles.erase(it); | 745 | it = allFiles.erase(it); |
| 745 | continue; | 746 | continue; |
| 746 | } | 747 | } |
| @@ -1333,7 +1333,8 @@ napi_value SessionRestoreNExporter::MigrateFile(napi_env env, napi_callback_info | |||
| 1333 | }; | 1333 | }; |
| 1334 | HILOGI("Called SessionRestore::MigrateFile end, srcPath: %{public}s, destPath: %{public}s, " | 1334 | HILOGI("Called SessionRestore::MigrateFile end, srcPath: %{public}s, destPath: %{public}s, " |
| 1335 | "bundleName: %{public}s, fileName: %{public}s.", | 1335 | "bundleName: %{public}s, fileName: %{public}s.", |
| 1336 | - pathInfo.srcPath.c_str(), pathInfo.destPath.c_str(), bundleName.c_str(), fileName.c_str()); | 1336 | + GetAnonyPath(pathInfo.srcPath).c_str(), GetAnonyPath(pathInfo.destPath).c_str(), |
| 1337 | + bundleName.c_str(), fileName.c_str()); | ||
| 1337 | 1338 | ||
| 1338 | NVal thisVar(env, funcArg.GetThisVar()); | 1339 | NVal thisVar(env, funcArg.GetThisVar()); |
| 1339 | return NAsyncWorkPromise(env, thisVar).Schedule(className, cbExec, cbCompl).val_; | 1340 | return NAsyncWorkPromise(env, thisVar).Schedule(className, cbExec, cbCompl).val_; |
| @@ -145,7 +145,7 @@ bool SABackupConnection::InputParaSet(MessageParcel &data) | |||
| 145 | if (extension_ == BConstants::EXTENSION_BACKUP) { | 145 | if (extension_ == BConstants::EXTENSION_BACKUP) { |
| 146 | if (!data.WriteString(extInfo_)) { | 146 | if (!data.WriteString(extInfo_)) { |
| 147 | HILOGE("InputParaSet WriteString failed sa: %{public}d, extInfo: %{public}s, extension: %{public}s", | 147 | HILOGE("InputParaSet WriteString failed sa: %{public}d, extInfo: %{public}s, extension: %{public}s", |
| 148 | - saId_, extInfo_.c_str(), extension_.c_str()); | 148 | + saId_, GetAnonyString(extInfo_).c_str(), extension_.c_str()); |
| 149 | return false; | 149 | return false; |
| 150 | } | 150 | } |
| 151 | return true; | 151 | return true; |
| @@ -353,10 +353,10 @@ ErrCode Service::AppAncoFileReady(const std::string &fileName, const std::string | |||
| 353 | auto fd = UniqueFd(enhanceService->OpenAncoFileReadOnly(filePath)); | 353 | auto fd = UniqueFd(enhanceService->OpenAncoFileReadOnly(filePath)); |
| 354 | if (fd < 0) { | 354 | if (fd < 0) { |
| 355 | errCode = errno; | 355 | errCode = errno; |
| 356 | - HILOGE("open file failed, filename: %{public}s, err: %{public}d", GetAnonyString(filePath).c_str(), | 356 | + HILOGE("open file failed, filename: %{public}s, err: %{public}d", GetAnonyPath(filePath).c_str(), |
| 357 | errCode); | 357 | errCode); |
| 358 | if (errCode == ERR_NO_PERMISSION) { | 358 | if (errCode == ERR_NO_PERMISSION) { |
| 359 | - HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyString(filePath).c_str()); | 359 | + HILOGW("noPermissionFile, don't need to backup, path: %{public}s", GetAnonyPath(filePath).c_str()); |
| 360 | return errCode; | 360 | return errCode; |
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| @@ -366,7 +366,7 @@ ErrCode Service::AppAncoFileReady(const std::string &fileName, const std::string | |||
| 366 | HILOGD("Report app file ready success, filename: %{public}s", fileName.c_str()); | 366 | HILOGD("Report app file ready success, filename: %{public}s", fileName.c_str()); |
| 367 | if (needDelete) { | 367 | if (needDelete) { |
| 368 | auto ret = enhanceService->RemoveAncoFile(filePath); | 368 | auto ret = enhanceService->RemoveAncoFile(filePath); |
| 369 | - HILOGD("RemoveFile result:%{public}d, filepath:%{public}s", ret, filePath.c_str()); | 369 | + HILOGD("RemoveFile result:%{public}d, filepath:%{public}s", ret, GetAnonyPath(filePath).c_str()); |
| 370 | } | 370 | } |
| 371 | } else { | 371 | } else { |
| 372 | HILOGW("Report app file ready failed, ret: %{public}d, filename: %{public}s", reportRs, fileName.c_str()); | 372 | HILOGW("Report app file ready failed, ret: %{public}d, filename: %{public}s", reportRs, fileName.c_str()); |
| @@ -891,22 +891,22 @@ void Service::OnBackupExtensionDied(const string &&bundleName, bool isCleanCalle | |||
| 891 | OnAllBundlesFinished(BError(BError::Codes::OK)); | 891 | OnAllBundlesFinished(BError(BError::Codes::OK)); |
| 892 | return; | 892 | return; |
| 893 | } | 893 | } |
| 894 | + string callName = std::move(bundleName); | ||
| 894 | try { | 895 | try { |
| 895 | - string callName = move(bundleName); | ||
| 896 | HILOGE("Backup <%{public}s> Extension Process Died", callName.c_str()); | 896 | HILOGE("Backup <%{public}s> Extension Process Died", callName.c_str()); |
| 897 | ErrCode ret = session_->VerifyBundleName(callName); | 897 | ErrCode ret = session_->VerifyBundleName(callName); |
| 898 | if (ret != ERR_OK) { | 898 | if (ret != ERR_OK) { |
| 899 | HILOGE("Backup Extension died error, verify bundleName failed, bundleName:%{public}s, ret:%{public}d", | 899 | HILOGE("Backup Extension died error, verify bundleName failed, bundleName:%{public}s, ret:%{public}d", |
| 900 | - bundleName.c_str(), ret); | 900 | + callName.c_str(), ret); |
| 901 | - ExtConnectDied(bundleName); | 901 | + ExtConnectDied(callName); |
| 902 | return; | 902 | return; |
| 903 | } | 903 | } |
| 904 | // 重新连接清理缓存 | 904 | // 重新连接清理缓存 |
| 905 | HILOGI("Clear backup extension data, bundleName: %{public}s", callName.c_str()); | 905 | HILOGI("Clear backup extension data, bundleName: %{public}s", callName.c_str()); |
| 906 | ExtConnectDied(callName); | 906 | ExtConnectDied(callName); |
| 907 | } catch (...) { | 907 | } catch (...) { |
| 908 | - HILOGE("Unexpected exception, bundleName: %{public}s", bundleName.c_str()); | 908 | + HILOGE("Unexpected exception, bundleName: %{public}s", callName.c_str()); |
| 909 | - ExtConnectDied(bundleName); | 909 | + ExtConnectDied(callName); |
| 910 | return; | 910 | return; |
| 911 | } | 911 | } |
| 912 | } | 912 | } |
| @@ -159,6 +159,10 @@ void ScanResultManager::AddAncoBigFile( | |||
| 159 | void ScanResultManager::AddAncoTarFile(const std::string &filename, const std::string &filePath, const struct stat &sta) | 159 | void ScanResultManager::AddAncoTarFile(const std::string &filename, const std::string &filePath, const struct stat &sta) |
| 160 | { | 160 | { |
| 161 | std::lock_guard<std::mutex> lock(pendingFileMutex_); | 161 | std::lock_guard<std::mutex> lock(pendingFileMutex_); |
| 162 | + if (sta.st_size < 0) { | ||
| 163 | + HILOGE("st_size is negative, fileName:%{public}s!", filename.c_str()); | ||
| 164 | + return; | ||
| 165 | + } | ||
| 162 | pendingFileQueue_.push(std::make_shared<AncoFileInfo>(filename, filePath, sta, false)); | 166 | pendingFileQueue_.push(std::make_shared<AncoFileInfo>(filename, filePath, sta, false)); |
| 163 | currentTarSize_.fetch_add(sta.st_size); | 167 | currentTarSize_.fetch_add(sta.st_size); |
| 164 | if (currentTarSize_.load() > GetMaxTarSize()) { | 168 | if (currentTarSize_.load() > GetMaxTarSize()) { |