From 104153bc18b14ca6d618b0b034b06768da4ba444 Mon Sep 17 00:00:00 2001 From: hughes Date: Fri, 11 Mar 2022 08:25:49 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20bdc9712=20from=20https://gitee.com/hugh?= =?UTF-8?q?es802/update=5Fupdater/pulls/89=20=E4=BF=AE=E6=94=B9=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E6=BC=8F=E6=B4=9E=20Signed-off-by:hughes802?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/package/pkg_package/pkg_upgradefile.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/package/pkg_package/pkg_upgradefile.cpp b/services/package/pkg_package/pkg_upgradefile.cpp index 85d4e1e0..72e466ea 100644 --- a/services/package/pkg_package/pkg_upgradefile.cpp +++ b/services/package/pkg_package/pkg_upgradefile.cpp @@ -326,6 +326,11 @@ int32_t UpgradePkgFile::ReadUpgradePkgHeader(const PkgBuffer &buffer, size_t &re PkgFile::ConvertBufferToString(pkgInfo_.productUpdateId, {header->productUpdateId, sizeof(header->productUpdateId)}); + algorithm = PkgAlgorithmFactory::GetDigestAlgorithm(pkgInfo_.pkgInfo.digestMethod); + PKG_CHECK(algorithm != nullptr, return PKG_NOT_EXIST_ALGORITHM, + "Invalid file %s", pkgStream_->GetFileName().c_str()); + algorithm->Init(); + if (currLen + tlv.length >= readLen) { // Extra TLV information, read it. realLen = currLen + tlv.length; algorithm->Update(buffer, realLen); @@ -348,10 +353,6 @@ int32_t UpgradePkgFile::ReadUpgradePkgHeader(const PkgBuffer &buffer, size_t &re realLen += currLen; // Parser header to get compressional algorithm - algorithm = PkgAlgorithmFactory::GetDigestAlgorithm(pkgInfo_.pkgInfo.digestMethod); - PKG_CHECK(algorithm != nullptr, return PKG_NOT_EXIST_ALGORITHM, - "Invalid file %s", pkgStream_->GetFileName().c_str()); - algorithm->Init(); algorithm->Update(buffer, currLen); // Generate digest return PKG_SUCCESS; } -- Gitee