From 1a70ef57ae6bac2a4c0009ce73795dc09ea6b39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Thu, 14 Aug 2025 20:04:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Signed-off-by:=20=E7=8E=8B=E4=BD=B3?= =?UTF-8?q?=E6=A0=8B=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- services/package/pkg_manager/pkg_managerImpl.cpp | 8 ++++---- services/package/pkg_verify/openssl_util.cpp | 1 - services/package/pkg_verify/pkg_verify_util.cpp | 9 ++++----- services/package/pkg_verify/pkg_verify_util.h | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/services/package/pkg_manager/pkg_managerImpl.cpp b/services/package/pkg_manager/pkg_managerImpl.cpp index 04f197a6..d7e17927 100644 --- a/services/package/pkg_manager/pkg_managerImpl.cpp +++ b/services/package/pkg_manager/pkg_managerImpl.cpp @@ -306,11 +306,11 @@ int32_t PkgManagerImpl::LoadPackage(const std::string &packagePath, const std::s PkgFile::PkgType pkgType = GetPkgTypeByName(packagePath); unzipToFile_ = ((pkgType == PkgFile::PKG_TYPE_GZIP) ? true : unzipToFile_); if (pkgType == PkgFile::PKG_TYPE_UPGRADE) { - if (LoadPackage(packagePath, fileIds, pkgType) != PKG_SUCCESS) { + if (int32_t ret = LoadPackage(packagePath, fileIds, pkgType) != PKG_SUCCESS) { ClearPkgFile(); - UPDATER_LAST_WORD("LoadPackage failed", packagePath); + UPDATER_LAST_WORD("LoadPackage failed", packagePath, ret); PKG_LOGE("Parse %s fail ", packagePath.c_str()); - return PKG_INVALID_FILE; + return ret; } } else if (pkgType != PkgFile::PKG_TYPE_NONE) { std::vector innerFileNames; @@ -368,7 +368,7 @@ int32_t PkgManagerImpl::ExtraAndLoadPackage(const std::string &path, const std:: (void)mkdir(tempPath.c_str(), 0775); // 0775 : rwxrwxr-x #endif } - + // Extract package to file or memory if (unzipToFile_ || type == PkgFile::PKG_TYPE_UPGRADE) { ret = CreatePkgStream(stream, tempPath + name + ".tmp", info->unpackedSize, PkgStream::PkgStreamType_Write); diff --git a/services/package/pkg_verify/openssl_util.cpp b/services/package/pkg_verify/openssl_util.cpp index 2554cc7d..ac4b2fa1 100644 --- a/services/package/pkg_verify/openssl_util.cpp +++ b/services/package/pkg_verify/openssl_util.cpp @@ -231,7 +231,6 @@ int32_t CalcSha256Digest(const PkgStreamPtr srcData, const size_t dataLen, std:: } SHA256_Update(&ctx, buffer.buffer, readLen); offset += readLen; - PKG_LOGI("use new remainLen"); remainLen -= readLen; } diff --git a/services/package/pkg_verify/pkg_verify_util.cpp b/services/package/pkg_verify/pkg_verify_util.cpp index 004f8b63..b128901b 100644 --- a/services/package/pkg_verify/pkg_verify_util.cpp +++ b/services/package/pkg_verify/pkg_verify_util.cpp @@ -210,7 +210,7 @@ std::string PkgVerifyUtil::GetPkgTime(const std::string &pkgPath) const return fileInfo; } -void PkgVerifyUtil::WriteHash(std::vector &hash, const std::string &pkgPath) const +void PkgVerifyUtil::RecordHash(std::vector &hash, const std::string &pkgPath) const { Updater::UPDATER_INIT_RECORD; std::string path = "/data/updater/hash_file"; @@ -220,7 +220,7 @@ void PkgVerifyUtil::WriteHash(std::vector &hash, const std::string &pkg PKG_LOGE("open file failed"); return; } - file.write(reinterpret_cast(hash.data()), sizeof(hash)); + file.write(reinterpret_cast(hash.data()), hash.size()); return; } std::ifstream file(path, std::ios::in); @@ -232,8 +232,7 @@ void PkgVerifyUtil::WriteHash(std::vector &hash, const std::string &pkg if (getline(file, lastHash)) { std::vector lastHashVector {}; lastHashVector.assign(lastHash.begin(), lastHash.end()); - UPDATER_LAST_WORD(ConvertShaHex(static_cast>(lastHashVector)), - ConvertShaHex(hash), GetPkgTime(pkgPath)); + UPDATER_LAST_WORD(ConvertShaHex(lastHashVector), ConvertShaHex(hash), GetPkgTime(pkgPath)); } } @@ -266,7 +265,7 @@ int32_t PkgVerifyUtil::HashCheck(const PkgStreamPtr srcData, const size_t dataLe UPDATER_LAST_WORD(PKG_INVALID_DIGEST, ConvertShaHex(hash).substr(0, INTERCEPT_HASH_LENGTH), ConvertShaHex(sourceDigest).substr(0, INTERCEPT_HASH_LENGTH), fileInfo); - WriteHash(sourceDigest, path); + RecordHash(sourceDigest, path); return PKG_INVALID_DIGEST; } diff --git a/services/package/pkg_verify/pkg_verify_util.h b/services/package/pkg_verify/pkg_verify_util.h index e4da7ed6..a13deca8 100644 --- a/services/package/pkg_verify/pkg_verify_util.h +++ b/services/package/pkg_verify/pkg_verify_util.h @@ -51,7 +51,7 @@ public: std::string GetPkgTime(const std::string &pkgPath) const; - void WriteHash(std::vector &hash, const std::string &pkgPath) const; + void RecordHash(std::vector &hash, const std::string &pkgPath) const; private: bool isOldSigSupport_ {true}; }; -- Gitee From 7900dd3dec81070283a275e748d85aad017cb11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=A0=8B?= Date: Sat, 16 Aug 2025 03:47:41 +0000 Subject: [PATCH 2/2] update services/package/pkg_manager/pkg_managerImpl.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王佳栋 --- services/package/pkg_manager/pkg_managerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/package/pkg_manager/pkg_managerImpl.cpp b/services/package/pkg_manager/pkg_managerImpl.cpp index d7e17927..f9834dbe 100644 --- a/services/package/pkg_manager/pkg_managerImpl.cpp +++ b/services/package/pkg_manager/pkg_managerImpl.cpp @@ -306,7 +306,7 @@ int32_t PkgManagerImpl::LoadPackage(const std::string &packagePath, const std::s PkgFile::PkgType pkgType = GetPkgTypeByName(packagePath); unzipToFile_ = ((pkgType == PkgFile::PKG_TYPE_GZIP) ? true : unzipToFile_); if (pkgType == PkgFile::PKG_TYPE_UPGRADE) { - if (int32_t ret = LoadPackage(packagePath, fileIds, pkgType) != PKG_SUCCESS) { + if (int32_t ret = LoadPackage(packagePath, fileIds, pkgType); ret != PKG_SUCCESS) { ClearPkgFile(); UPDATER_LAST_WORD("LoadPackage failed", packagePath, ret); PKG_LOGE("Parse %s fail ", packagePath.c_str()); -- Gitee