已开启
Check the return value #2264
dongtingchi创建于 8月25日
Check the return value #2264
已开启
共 5 个文件变更+15-1
| @@ -516,7 +516,10 @@ bool TarFile::CompleteBlock(off_t size) | |||
| 516 | int append = BLOCK_SIZE - (size % BLOCK_SIZE); | 516 | int append = BLOCK_SIZE - (size % BLOCK_SIZE); |
| 517 | vector<uint8_t> buff {}; | 517 | vector<uint8_t> buff {}; |
| 518 | buff.resize(append); | 518 | buff.resize(append); |
| 519 | - WriteAll(buff, append); | 519 | + if (static_cast<size_t>(WriteAll(buff, append)) != static_cast<size_t>(append)) { |
| 520 | + HILOGE("CompleteBlock write failed"); | ||
| 521 | + return false; | ||
| 522 | + } | ||
| 520 | } | 523 | } |
| 521 | return true; | 524 | return true; |
| 522 | } | 525 | } |
| @@ -952,6 +952,7 @@ ErrCode Service::SendIncrementalFileHandle(const std::string &bundleName, const | |||
| 952 | AppRadar::Info info (bundleName, "", ""); | 952 | AppRadar::Info info (bundleName, "", ""); |
| 953 | AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetIncrementalFileHandle", | 953 | AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetIncrementalFileHandle", |
| 954 | GetUserIdDefault(), BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, err); | 954 | GetUserIdDefault(), BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, err); |
| 955 | + return err; | ||
| 955 | } | 956 | } |
| 956 | return BError(BError::Codes::OK); | 957 | return BError(BError::Codes::OK); |
| 957 | } | 958 | } |
| @@ -465,6 +465,11 @@ ErrCode Service::ProcessReadyFiles( | |||
| 465 | const std::vector<int>& errCodes, | 465 | const std::vector<int>& errCodes, |
| 466 | const std::string& callerName) | 466 | const std::string& callerName) |
| 467 | { | 467 | { |
| 468 | + if (fileNames.size() != errCodes.size()) { | ||
| 469 | + HILOGE("fileNames size %{public}zu != errCodes size %{public}zu", | ||
| 470 | + fileNames.size(), errCodes.size()); | ||
| 471 | + return BError(BError::Codes::SA_INVAL_ARG); | ||
| 472 | + } | ||
| 468 | for (size_t i = 0; i < fileNames.size(); ++i) { | 473 | for (size_t i = 0; i < fileNames.size(); ++i) { |
| 469 | string fileName = fileNames[i]; | 474 | string fileName = fileNames[i]; |
| 470 | int errCode = errCodes[i]; | 475 | int errCode = errCodes[i]; |
| @@ -383,6 +383,10 @@ ErrCode MigrateManager::ScanAllDirs(int64_t &totalSize, const string &bundleName | |||
| 383 | return BError(BError::Codes::OK); | 383 | return BError(BError::Codes::OK); |
| 384 | } | 384 | } |
| 385 | auto ret = enhanceService->MakeDir(bundleName); | 385 | auto ret = enhanceService->MakeDir(bundleName); |
| 386 | + if (ret != ERR_OK) { | ||
| 387 | + HILOGE("MakeDir failed, ret:%{public}d", ret); | ||
| 388 | + return ret; | ||
| 389 | + } | ||
| 386 | 390 | ||
| 387 | auto instance = GetScanInstance(bundleName); | 391 | auto instance = GetScanInstance(bundleName); |
| 388 | if (instance == nullptr) { | 392 | if (instance == nullptr) { |
| @@ -216,6 +216,7 @@ ErrCode Service::SendDefaultIncrementalFileHandle(const std::string &bundleName, | |||
| 216 | if (err != ERR_OK) { | 216 | if (err != ERR_OK) { |
| 217 | HILOGE("Failed to send file handle, bundleName:%{public}s, fileName:%{public}s", | 217 | HILOGE("Failed to send file handle, bundleName:%{public}s, fileName:%{public}s", |
| 218 | bundleName.c_str(), GetAnonyPath(fileName).c_str()); | 218 | bundleName.c_str(), GetAnonyPath(fileName).c_str()); |
| 219 | + return err; | ||
| 219 | } | 220 | } |
| 220 | return BError(BError::Codes::OK); | 221 | return BError(BError::Codes::OK); |
| 221 | } | 222 | } |