diff --git a/src/common/file.cpp b/src/common/file.cpp index 9001a3d69180ff3fa541d1b439f9c6f3c7bd1115..645ea274f1a1383ed40d92637ef26e40b674e6b2 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -529,10 +529,11 @@ void HdcFile::TransferNext(CtxFile *context) context->localPath = context->localDirName + context->localName; context->taskQueue.pop_back(); WRITE_LOG(LOG_DEBUG, "TransferNext localPath = %s queuesize:%d", - context->localPath.c_str(), ctxNow.taskQueue.size()); + Hdc::MaskString(context->localPath).c_str(), ctxNow.taskQueue.size()); uv_fs_t *openReq = new uv_fs_t; if (openReq == nullptr) { - WRITE_LOG(LOG_FATAL, "HdcFile::TransferNext new openReq failed for file %s", context->localPath.c_str()); + WRITE_LOG(LOG_FATAL, "HdcFile::TransferNext new openReq failed for file %s", + Hdc::MaskString(context->localPath).c_str()); OnFileOpenFailed(context); return; } diff --git a/src/common/transfer.cpp b/src/common/transfer.cpp index 4eac6129ccef82c7a970baf1d65a2685bac729f4..92c98d2ba5d383fe045ce9f79d12c71a7a14a935 100644 --- a/src/common/transfer.cpp +++ b/src/common/transfer.cpp @@ -201,7 +201,8 @@ bool HdcTransferBase::SendIOPayload(CtxFile *context, uint64_t index, uint8_t *d compressSize = LZ4_compress_default((const char *)data, (char *)sendBuf + payloadPrefixReserve, dataSize, dataSize); if (compressSize <= 0) { - WRITE_LOG(LOG_DEBUG, "LZ4 compress failed, path: %s compress none", context->localPath.c_str()); + WRITE_LOG(LOG_DEBUG, "LZ4 compress failed, path: %s compress none", + context->localPath.c_str()); delete[] sendBuf; payloadHead.compressType = COMPRESS_NONE; compressSize = dataSize; @@ -340,15 +341,19 @@ bool HdcTransferBase::ProcressFileIOIsSuccess(uv_fs_t *req, CtxFile *context, ui uv_fs_t fs = {}; int ret = uv_fs_statfs(nullptr, &fs, context->localPath.c_str(), nullptr); if (ret < 0) { + constexpr int size = 1024; + char buf[size] = { 0 }; + uv_strerror_r(ret, buf, size); WRITE_LOG(LOG_WARN, "CheckSpace error querying filesystem: %s, path: %s", - uv_strerror(ret), context->localPath.c_str()); + buf, context->localPath.c_str()); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast(abs(ret)); return false; } uv_statfs_t* statfs = static_cast(fs.ptr); uint64_t freeBytes = statfs->f_bsize * statfs->f_bfree; - WRITE_LOG(LOG_DEBUG, "CheckSpace, path: %s, freeBytes: %llu", context->localPath.c_str(), freeBytes); + WRITE_LOG(LOG_DEBUG, "CheckSpace, path: %s, freeBytes: %llu", + context->localPath.c_str(), freeBytes); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast((freeBytes == 0) ? ENOSPC : EIO); return false; @@ -439,7 +444,8 @@ void HdcTransferBase::RemoveSandboxRootPath(std::string &srcStr, const std::stri if ((pos = srcStr.find(fullPath)) != std::string::npos) { srcStr = srcStr.replace(pos, fullPath.length(), ""); } else { - WRITE_LOG(LOG_DEBUG, "fullPath:%s, srcStr:%s", fullPath.c_str(), srcStr.c_str()); + WRITE_LOG(LOG_DEBUG, "fullPath:%s, srcStr:%s", Hdc::MaskString(fullPath).c_str(), + Hdc::MaskString(srcStr).c_str()); } } @@ -461,7 +467,8 @@ void HdcTransferBase::OnFileOpen(uv_fs_t *req) thisClass->RemoveSandboxRootPath(localPath, context->bundleName); thisClass->LogMsg(MSG_FAIL, "Error opening file: %s, path:%s", buf, localPath.c_str()); - WRITE_LOG(LOG_FATAL, "open path:%s, localPath:%s, error:%s, dir:%d, master:%d", context->localPath.c_str(), + WRITE_LOG(LOG_FATAL, "open path:%s, localPath:%s, error:%s, dir:%d, master:%d", + context->localPath.c_str(), localPath.c_str(), buf, context->isDir, context->master); OnFileOpenFailed(context); return; @@ -636,7 +643,8 @@ int HdcTransferBase::GetSubFilesRecursively(string path, string currentDirname, bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string &errStr) { // If optName show this is directory mode, check localPath and try create each layer - WRITE_LOG(LOG_DEBUG, "CheckDirectory localPath = %s optName = %s", localPath.c_str(), optName.c_str()); + WRITE_LOG(LOG_DEBUG, "CheckDirectory localPath = %s optName = %s", + localPath.c_str(), optName.c_str()); if ((optName.find('/') == string::npos) && (optName.find('\\') == string::npos)) { WRITE_LOG(LOG_DEBUG, "Not directory mode optName = %s, return", optName.c_str()); return true; @@ -653,7 +661,8 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string if (dirsOflocalPath.size() > 0 && !ctxNow.isDir && localPath.back() != Base::GetPathSep()) { dirsOflocalPath.pop_back(); } - WRITE_LOG(LOG_DEBUG, "localPath = %s dir layers = %zu", localPath.c_str(), dirsOflocalPath.size()); + WRITE_LOG(LOG_DEBUG, "localPath = %s dir layers = %zu", + localPath.c_str(), dirsOflocalPath.size()); string makedirPath; if (!Base::IsAbsolutePath(localPath)) { makedirPath = "."; @@ -747,7 +756,8 @@ bool HdcTransferBase::CheckFilename(string &localPath, string &optName, string & } } - WRITE_LOG(LOG_DEBUG, "CheckFilename finish localPath:%s optName:%s", localPath.c_str(), optName.c_str()); + WRITE_LOG(LOG_DEBUG, "CheckFilename finish localPath:%s optName:%s", + Hdc::MaskString(localPath).c_str(), optName.c_str()); return true; } diff --git a/src/common/transfer.h b/src/common/transfer.h index 7c54d871577048b73c9394e99903c54ae0d4b91b..c9a11eeb2e5687cf5b4d71f826975e1e72bfdb47 100644 --- a/src/common/transfer.h +++ b/src/common/transfer.h @@ -150,7 +150,7 @@ protected: return; } WRITE_LOG(LOG_DEBUG, "CloseCtxFd, localPath:%s result:%d, closeReqSubmitted:%d", - context->localPath.c_str(), context->openFd, context->closeReqSubmitted); + Hdc::MaskString(context->localPath).c_str(), context->openFd, context->closeReqSubmitted); uv_fs_t fs; uv_fs_close(nullptr, &fs, context->openFd, nullptr); uv_fs_req_cleanup(&fs); diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index 0e5a202d6ef6516b1ce577c6e92a4733475a1dcb..19166e40634b3cc1064b7fa939b44553bbdc391e 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -630,7 +630,7 @@ void HdcServerForClient::HandleRemote(HChannel hChannel, string ¶meters, Rem string remote = CMDSTR_REMOTE_PARAMETER + " "; if (parameters.find(remote) != std::string::npos) { parameters.replace(parameters.find(remote), remote.size(), ""); - WRITE_LOG(LOG_DEBUG, "parameters: %s", parameters.c_str()); + WRITE_LOG(LOG_DEBUG, "parameters: %s", Hdc::MaskString(parameters).c_str()); } } delete[](reinterpret_cast(argv)); @@ -880,8 +880,8 @@ int HdcServerForClient::ReadChannel(HChannel hChannel, uint8_t *bufPtr, const in EchoClient(hChannel, MSG_FAIL, retEcho.c_str()); } } - WRITE_LOG(LOG_DEBUG, "ReadChannel cid:%u sid:%u key:%s command: %s", - hChannel->channelId, hChannel->targetSessionId, Hdc::MaskString(hChannel->connectKey).c_str(), bufPtr); + WRITE_LOG(LOG_DEBUG, "ReadChannel cid:%u sid:%u key:%s", hChannel->channelId, + hChannel->targetSessionId, Hdc::MaskString(hChannel->connectKey).c_str()); if (formatCommand.bJumpDo) { WRITE_LOG(LOG_FATAL, "ReadChannel bJumpDo true"); return -10; // -10 error formatCommand