From e7905eb4df5db7df97d7684013a39dc5c9131f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 18 Aug 2025 12:07:37 +0000 Subject: [PATCH 01/43] update services/package/pkg_package/pkg_upgradefile.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/package/pkg_package/pkg_upgradefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/package/pkg_package/pkg_upgradefile.cpp b/services/package/pkg_package/pkg_upgradefile.cpp index 75058896..ec8cc565 100644 --- a/services/package/pkg_package/pkg_upgradefile.cpp +++ b/services/package/pkg_package/pkg_upgradefile.cpp @@ -425,7 +425,7 @@ int32_t UpgradePkgFile::ReadPackageInfo(std::vector &signData, size_t & } } - ret = memset_s(buffer.buffer + UPGRADE_RESERVE_LEN, buffer.length, 0, GetUpgradeSignatureLen()); + ret = memset_s(buffer.buffer + UPGRADE_RESERVE_LEN, buffer.length - UPGRADE_RESERVE_LEN, 0, GetUpgradeSignatureLen()); if (ret != EOK) { PKG_LOGE("memset buff fail"); UPDATER_LAST_WORD(PKG_NONE_MEMORY, "memset buff fail"); -- Gitee From d0ffeb6470a7735b2b5597bbcd92df52c503dcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 18 Aug 2025 12:11:38 +0000 Subject: [PATCH 02/43] update services/flow_update/update_bin/bin_flow_update.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/flow_update/update_bin/bin_flow_update.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/flow_update/update_bin/bin_flow_update.cpp b/services/flow_update/update_bin/bin_flow_update.cpp index fbd469c7..023448d7 100644 --- a/services/flow_update/update_bin/bin_flow_update.cpp +++ b/services/flow_update/update_bin/bin_flow_update.cpp @@ -91,8 +91,12 @@ int32_t BinFlowUpdate::StartBinFlowUpdate(uint8_t *data, uint32_t len) bool BinFlowUpdate::AddRemainData(uint8_t *data, uint32_t &len) { + if (curlen_ >= maxBufSize_) { + LOG(ERROR) << "curlen_ failed"; + return false; + } uint32_t copySize = std::min(static_cast(len), static_cast(maxBufSize_ - curlen_)); - if (memcpy_s(buffer_ + curlen_, maxBufSize_, data, copySize) != EOK) { + if (memcpy_s(buffer_ + curlen_, maxBufSize_ - curlen_, data, copySize) != EOK) { LOG(ERROR) << "AddRemainData memcpy failed" << " : " << strerror(errno); return false; } -- Gitee From 3580e977cdc354501d6f99d2c99d8f9010568a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 18 Aug 2025 12:49:49 +0000 Subject: [PATCH 03/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index a8078d1f..f955174f 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,6 +310,11 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } + if (deviceBlockSize >=TMP_DATA_SIZE || imgBlockSize > (TMP_DATA_SIZE - deviceBlockSize) || + GPT_ENTRYS_SIZE > (TMP_DATA_SIZE - 2 * deviceBlockSize)) { + LOG(ERROR) << "memcpy_s size fail"; + return false; + } // for hisi: change ptable.img(512 bytes/block) into format of device(4096 bytes/block) if (memcpy_s(newLunPtnDataInfo.data, TMP_DATA_SIZE, lunStart, imgBlockSize) != EOK) { LOG(WARNING) << "memcpy_s pmbr fail"; @@ -565,8 +570,13 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart - imageBuf), newBuf.data(), editLen) != 0) { - LOG(ERROR) << "memcpy fail. destSize :" << imgBufSize - (ufsLunEntryStart - imageBuf); + size_t destSize = imgBufSize - (ufsLunEntryStart - imageBuf); + if ((ufsLunEntryStart - imageBuf) >= imgBufSize || editLen > destSize){ + LOG(ERROR) << "memcpy size fail destSize" << destSize << "editLen" << editLen; + return false; + } + if (memcpy_s(ufsLunEntryStart, destSize, newBuf.data(), editLen) != 0) { + LOG(ERROR) << "memcpy fail. destSize :" << destSize; return false; } return true; -- Gitee From f08fbd42fecdc7fcef6508abd057bbd06c10a4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:07:45 +0000 Subject: [PATCH 04/43] update services/diffpatch/bzip2/lz4_adapter.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/bzip2/lz4_adapter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/diffpatch/bzip2/lz4_adapter.cpp b/services/diffpatch/bzip2/lz4_adapter.cpp index 5ec2c8a1..9897f6d2 100644 --- a/services/diffpatch/bzip2/lz4_adapter.cpp +++ b/services/diffpatch/bzip2/lz4_adapter.cpp @@ -113,7 +113,7 @@ int32_t Lz4FrameAdapter::WriteData(const BlockBuffer &srcData) size_t blockSize = LZ4_BLOCK_SIZE(blockSizeID_); int32_t ret = 0; if ((currDataSize_ + srcData.length) < inData_.size()) { - ret = memcpy_s(inData_.data() + currDataSize_, inData_.size(), srcData.buffer, srcData.length); + ret = memcpy_s(inData_.data() + currDataSize_, inData_.size() - currDataSize_, srcData.buffer, srcData.length); if (ret != 0) { PATCH_LOGE("Failed to copy data "); return -1; @@ -121,7 +121,7 @@ int32_t Lz4FrameAdapter::WriteData(const BlockBuffer &srcData) currDataSize_ += srcData.length; } else { size_t hasCopyLen = inData_.size() - currDataSize_; - ret = memcpy_s(inData_.data() + currDataSize_, inData_.size(), srcData.buffer, hasCopyLen); + ret = memcpy_s(inData_.data() + currDataSize_, hasCopyLen, srcData.buffer, hasCopyLen); if (ret != 0) { PATCH_LOGE("Failed to copy data "); return -1; -- Gitee From fe19877e014b9de88643feb31ef356a76ce1dec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:12:30 +0000 Subject: [PATCH 05/43] update services/diffpatch/diff/update_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/update_diff.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/diffpatch/diff/update_diff.cpp b/services/diffpatch/diff/update_diff.cpp index bb35a117..048e4b5c 100644 --- a/services/diffpatch/diff/update_diff.cpp +++ b/services/diffpatch/diff/update_diff.cpp @@ -111,7 +111,11 @@ int32_t ImageParser::Extract(const std::string &fileName, std::vector & if ((start + bufferSize) > buffer.size()) { buffer.resize(IGMDIFF_LIMIT_UNIT * ((start + bufferSize) / IGMDIFF_LIMIT_UNIT + 1)); } - return memcpy_s(buffer.data() + start, buffer.size(), data.buffer, size); + if (memcpy_s(buffer.data() + start, buffer.size() - start, data.buffer, size) != EOK) { + PATCH_LOGE("Failed to memcpy_s data"); + return -1; + } + return 0; }, nullptr); if (ret != 0) { PATCH_LOGE("Failed to extract data"); -- Gitee From 7a27c650f7cd70fee0ac01a97eb27f80b0c22862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:16:04 +0000 Subject: [PATCH 06/43] update services/diffpatch/diff/image_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/image_diff.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/diffpatch/diff/image_diff.cpp b/services/diffpatch/diff/image_diff.cpp index f36ea15b..6322c745 100644 --- a/services/diffpatch/diff/image_diff.cpp +++ b/services/diffpatch/diff/image_diff.cpp @@ -584,7 +584,11 @@ int32_t CompressedImageDiff::CompressData(Hpackage::PkgManager::FileInfoPtr info if ((start + outSize) > outData.size()) { outData.resize(IGMDIFF_LIMIT_UNIT * ((start + outSize) / IGMDIFF_LIMIT_UNIT + 1)); } - return memcpy_s(outData.data() + start, outData.size(), data.buffer, size); + if (memcpy_s(outData.data() + start, outData.size() - start, data.buffer, size) != EOK) { + PATCH_LOGE("Failed to memcpy_s data"); + return -1; + } + return 0; }, nullptr); int32_t ret = pkgManager->CompressBuffer(info, {buffer.buffer, buffer.length}, stream1); if (ret != 0) { -- Gitee From 82aafc7869d21f2d811c5a79dec57b295d8b4a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:19:41 +0000 Subject: [PATCH 07/43] update services/diffpatch/diff/blocks_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/blocks_diff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/diffpatch/diff/blocks_diff.cpp b/services/diffpatch/diff/blocks_diff.cpp index 29d4fab2..dc1945e1 100644 --- a/services/diffpatch/diff/blocks_diff.cpp +++ b/services/diffpatch/diff/blocks_diff.cpp @@ -228,7 +228,7 @@ int32_t BlocksBufferDiff::WritePatchHeader(int64_t controlSize, return -1; } - int32_t ret = memcpy_s(patchData_.data() + offset_, patchData_.size(), BSDIFF_MAGIC, + int32_t ret = memcpy_s(patchData_.data() + offset_, patchData_.size() - offset_, BSDIFF_MAGIC, std::char_traits::length(BSDIFF_MAGIC)); if (ret != 0) { PATCH_LOGE("Failed to copy magic"); -- Gitee From 02262d46487df6302aa6702a98240008e47516d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:28:29 +0000 Subject: [PATCH 08/43] update services/log/log.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/log/log.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/log/log.cpp b/services/log/log.cpp index 00b3f8b4..d35456cb 100644 --- a/services/log/log.cpp +++ b/services/log/log.cpp @@ -128,10 +128,17 @@ std::ostream& StageLogger::OutputUpdaterStage() void Logger(int level, const char* fileName, int32_t line, const char* format, ...) { - std::vector buff(1024); // 1024 : max length of buff va_list list; va_start(list, format); - int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.capacity(), buff.capacity(), format, list); + int requiredSize = _vscprintf(format, list); + va_end(list); + if (requiredSize < 0) { + UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "Invalid format string"; + return; + } + std::vector buff(requiredSize + 1); + va_start(list, format); + int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.size(), requiredSize, format, list); va_end(list); if (size < EOK) { UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "vsnprintf_s failed"; -- Gitee From ac1a878d8dad0343337ab456c4a50c449c035b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 01:50:28 +0000 Subject: [PATCH 09/43] update utils/utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- utils/utils.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index 981ad9bf..a16ffcf7 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -842,13 +842,22 @@ void SetMessageToMisc(const std::string &miscCmd, const int message, const std:: return; } std::vector args = ParseParams(0, nullptr); + if (args.empty()) { + LOG(ERROR) << "No arguments parsed"; + return; + } struct UpdateMessage msg {}; if (!ReadUpdaterMiscMsg(msg)) { LOG(ERROR) << "SetMessageToMisc read misc failed"; return; } + size_t cmdSize = miscCmd.size(); + if (cmdSize >= sizeof(msg.command)) { + LOG(ERROR) << "Command exceeds maximum size"; + return; + } (void)memset_s(msg.command, sizeof(msg.command), 0, sizeof(msg.command)); - if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), miscCmd.size() + 1) != EOK) { + if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), cmdSize + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } @@ -894,8 +903,13 @@ void SetCmdToMisc(const std::string &miscCmd) return; } + size_t cmdSize = miscCmd.size(); + if (cmdSize >= sizeof(msg.command)) { + LOG(ERROR) << "Command exceeds maximum size"; + return; + } (void)memset_s(msg.command, sizeof(msg.command), 0, sizeof(msg.command)); - if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), miscCmd.size() + 1) != EOK) { + if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), cmdSize + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } @@ -923,6 +937,11 @@ void SetFaultInfoToMisc(const std::string &faultInfo) return; } + size_t faultInfoSize = faultInfo.size(); + if(faultInfoSize >= sizeof(msg.faultInfo)) { + LOG(ERROR) << "faultInfo exceeds maximum size"; + return; + } (void)memset_s(msg.faultinfo, sizeof(msg.faultinfo), 0, sizeof(msg.faultinfo)); if (strncpy_s(msg.faultinfo, sizeof(msg.faultinfo), faultInfo.c_str(), faultInfo.size() + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; -- Gitee From 9acee22baccb7fa11bf492258bd0059681a118fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 02:03:43 +0000 Subject: [PATCH 10/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index f955174f..2c79d4f9 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,7 +310,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } - if (deviceBlockSize >=TMP_DATA_SIZE || imgBlockSize > (TMP_DATA_SIZE - deviceBlockSize) || + if (deviceBlockSize >= TMP_DATA_SIZE || imgBlockSize > (TMP_DATA_SIZE - deviceBlockSize) || GPT_ENTRYS_SIZE > (TMP_DATA_SIZE - 2 * deviceBlockSize)) { LOG(ERROR) << "memcpy_s size fail"; return false; -- Gitee From b19ef30ff48685dd830fde1cb53956ef1ca6a72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 02:08:19 +0000 Subject: [PATCH 11/43] update utils/utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index a16ffcf7..fe9e48a4 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -943,7 +943,7 @@ void SetFaultInfoToMisc(const std::string &faultInfo) return; } (void)memset_s(msg.faultinfo, sizeof(msg.faultinfo), 0, sizeof(msg.faultinfo)); - if (strncpy_s(msg.faultinfo, sizeof(msg.faultinfo), faultInfo.c_str(), faultInfo.size() + 1) != EOK) { + if (strncpy_s(msg.faultinfo, sizeof(msg.faultinfo), faultInfo.c_str(), faultInfoSize + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } -- Gitee From dce65f9a1e217624398fc5fd8ee0579f10206e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 19 Aug 2025 02:22:01 +0000 Subject: [PATCH 12/43] update services/log/log.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/log/log.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/log/log.cpp b/services/log/log.cpp index d35456cb..ba31c8ce 100644 --- a/services/log/log.cpp +++ b/services/log/log.cpp @@ -144,6 +144,7 @@ void Logger(int level, const char* fileName, int32_t line, const char* format, . UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "vsnprintf_s failed"; return; } + buff[requiredSize] = "\0"; std::string str(buff.data(), size); UpdaterLogger(level).OutputUpdaterLog(fileName, line) << str; } -- Gitee From 0865a7e7fdeb2f6de4c238c2ad8e1a6debb2930e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Wed, 20 Aug 2025 08:02:55 +0000 Subject: [PATCH 13/43] update services/diffpatch/bzip2/lz4_adapter.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/bzip2/lz4_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/diffpatch/bzip2/lz4_adapter.cpp b/services/diffpatch/bzip2/lz4_adapter.cpp index 9897f6d2..f9959091 100644 --- a/services/diffpatch/bzip2/lz4_adapter.cpp +++ b/services/diffpatch/bzip2/lz4_adapter.cpp @@ -112,7 +112,7 @@ int32_t Lz4FrameAdapter::WriteData(const BlockBuffer &srcData) { size_t blockSize = LZ4_BLOCK_SIZE(blockSizeID_); int32_t ret = 0; - if ((currDataSize_ + srcData.length) < inData_.size()) { + if (currDataSize_ < inData_.size() && srcData.length < (inData_.size() - currDataSize_)) { ret = memcpy_s(inData_.data() + currDataSize_, inData_.size() - currDataSize_, srcData.buffer, srcData.length); if (ret != 0) { PATCH_LOGE("Failed to copy data "); -- Gitee From 000047410ed52758697aac927ed0a391c0cefac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Thu, 21 Aug 2025 08:49:13 +0000 Subject: [PATCH 14/43] update services/diffpatch/bzip2/lz4_adapter.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/bzip2/lz4_adapter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/diffpatch/bzip2/lz4_adapter.cpp b/services/diffpatch/bzip2/lz4_adapter.cpp index f9959091..21a01933 100644 --- a/services/diffpatch/bzip2/lz4_adapter.cpp +++ b/services/diffpatch/bzip2/lz4_adapter.cpp @@ -119,6 +119,9 @@ int32_t Lz4FrameAdapter::WriteData(const BlockBuffer &srcData) return -1; } currDataSize_ += srcData.length; + } else if (currDataSize_ >= inData_.size()) { + PATCH_LOGE("Failed to size "); + return -1; } else { size_t hasCopyLen = inData_.size() - currDataSize_; ret = memcpy_s(inData_.data() + currDataSize_, hasCopyLen, srcData.buffer, hasCopyLen); -- Gitee From 2e05050cba83e40eca7a63cadbba369360e49cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Fri, 22 Aug 2025 07:21:04 +0000 Subject: [PATCH 15/43] update services/diffpatch/diff/blocks_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/blocks_diff.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/diffpatch/diff/blocks_diff.cpp b/services/diffpatch/diff/blocks_diff.cpp index dc1945e1..70a8fa8a 100644 --- a/services/diffpatch/diff/blocks_diff.cpp +++ b/services/diffpatch/diff/blocks_diff.cpp @@ -223,8 +223,9 @@ int32_t BlocksBufferDiff::WritePatchHeader(int64_t controlSize, int64_t diffDataSize, int64_t newSize, size_t &headerLen) { headerLen = std::char_traits::length(BSDIFF_MAGIC) + sizeof(int64_t) + sizeof(int64_t) + sizeof(int64_t); - if (patchData_.size() <= headerLen + offset_) { - PATCH_LOGE("Invalid patch size"); + if (headerLen >= patchData_.size() || offset_ >= (patchData_.size - headerLen)) { + PATCH_LOGE("Invalid patch size headerLen = %zu, offset_ = %zu, patchData_.size = %zu", + headerLen, offset_, patchData_.size()); return -1; } -- Gitee From e62082a1dd5645cb41969abe4717db2cf8856b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Fri, 22 Aug 2025 07:24:33 +0000 Subject: [PATCH 16/43] update services/log/log.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/log/log.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/services/log/log.cpp b/services/log/log.cpp index ba31c8ce..e231eb84 100644 --- a/services/log/log.cpp +++ b/services/log/log.cpp @@ -128,23 +128,15 @@ std::ostream& StageLogger::OutputUpdaterStage() void Logger(int level, const char* fileName, int32_t line, const char* format, ...) { + std::vector buff(1024); // 1024 : max length of buff va_list list; va_start(list, format); - int requiredSize = _vscprintf(format, list); - va_end(list); - if (requiredSize < 0) { - UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "Invalid format string"; - return; - } - std::vector buff(requiredSize + 1); - va_start(list, format); - int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.size(), requiredSize, format, list); + int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.size(), buff.size() - 1, format, list); va_end(list); if (size < EOK) { UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "vsnprintf_s failed"; return; } - buff[requiredSize] = "\0"; std::string str(buff.data(), size); UpdaterLogger(level).OutputUpdaterLog(fileName, line) << str; } -- Gitee From de30103fce3ce297875294251bdcd984a54babe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Fri, 22 Aug 2025 07:35:12 +0000 Subject: [PATCH 17/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 2c79d4f9..80d7334d 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,8 +310,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } - if (deviceBlockSize >= TMP_DATA_SIZE || imgBlockSize > (TMP_DATA_SIZE - deviceBlockSize) || - GPT_ENTRYS_SIZE > (TMP_DATA_SIZE - 2 * deviceBlockSize)) { + if (TMP_DATA_SIZE <= 2 * deviceBlockSize)) { LOG(ERROR) << "memcpy_s size fail"; return false; } @@ -570,13 +569,13 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - size_t destSize = imgBufSize - (ufsLunEntryStart - imageBuf); - if ((ufsLunEntryStart - imageBuf) >= imgBufSize || editLen > destSize){ - LOG(ERROR) << "memcpy size fail destSize" << destSize << "editLen" << editLen; + if ((ufsLunEntryStart - imageBuf) >= imgBufSize){ + LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart + "imgBufSize" << imgBufSize; return false; } - if (memcpy_s(ufsLunEntryStart, destSize, newBuf.data(), editLen) != 0) { - LOG(ERROR) << "memcpy fail. destSize :" << destSize; + if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart -imageBuf), newBuf.data(), editLen) != 0) { + LOG(ERROR) << "memcpy fail. destSize :" << imgBufSize - (ufsLunEntryStart - imageBuf); return false; } return true; -- Gitee From 972b580ab0fc362c7c98c9af23d14acbeb404db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Fri, 22 Aug 2025 07:38:54 +0000 Subject: [PATCH 18/43] update utils/utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- utils/utils.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index fe9e48a4..981ad9bf 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -842,22 +842,13 @@ void SetMessageToMisc(const std::string &miscCmd, const int message, const std:: return; } std::vector args = ParseParams(0, nullptr); - if (args.empty()) { - LOG(ERROR) << "No arguments parsed"; - return; - } struct UpdateMessage msg {}; if (!ReadUpdaterMiscMsg(msg)) { LOG(ERROR) << "SetMessageToMisc read misc failed"; return; } - size_t cmdSize = miscCmd.size(); - if (cmdSize >= sizeof(msg.command)) { - LOG(ERROR) << "Command exceeds maximum size"; - return; - } (void)memset_s(msg.command, sizeof(msg.command), 0, sizeof(msg.command)); - if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), cmdSize + 1) != EOK) { + if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), miscCmd.size() + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } @@ -903,13 +894,8 @@ void SetCmdToMisc(const std::string &miscCmd) return; } - size_t cmdSize = miscCmd.size(); - if (cmdSize >= sizeof(msg.command)) { - LOG(ERROR) << "Command exceeds maximum size"; - return; - } (void)memset_s(msg.command, sizeof(msg.command), 0, sizeof(msg.command)); - if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), cmdSize + 1) != EOK) { + if (strncpy_s(msg.command, sizeof(msg.command), miscCmd.c_str(), miscCmd.size() + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } @@ -937,13 +923,8 @@ void SetFaultInfoToMisc(const std::string &faultInfo) return; } - size_t faultInfoSize = faultInfo.size(); - if(faultInfoSize >= sizeof(msg.faultInfo)) { - LOG(ERROR) << "faultInfo exceeds maximum size"; - return; - } (void)memset_s(msg.faultinfo, sizeof(msg.faultinfo), 0, sizeof(msg.faultinfo)); - if (strncpy_s(msg.faultinfo, sizeof(msg.faultinfo), faultInfo.c_str(), faultInfoSize + 1) != EOK) { + if (strncpy_s(msg.faultinfo, sizeof(msg.faultinfo), faultInfo.c_str(), faultInfo.size() + 1) != EOK) { LOG(ERROR) << "SetMessageToMisc strncpy_s failed"; return; } -- Gitee From 07a28969c14b1c70e6cc83afe8589cd57879c5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 01:24:00 +0000 Subject: [PATCH 19/43] 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/package/pkg_manager/pkg_managerImpl.cpp b/services/package/pkg_manager/pkg_managerImpl.cpp index 04f197a6..7a6bacc0 100644 --- a/services/package/pkg_manager/pkg_managerImpl.cpp +++ b/services/package/pkg_manager/pkg_managerImpl.cpp @@ -861,6 +861,9 @@ int32_t PkgManagerImpl::GenerateFileDigest(PkgStreamPtr stream, if (digestMethod != PKG_DIGEST_TYPE_SHA256) { buffer = buff.buffer + SIGN_SHA256_LEN; } + if (digestInfos[DIGEST_INFO_SIGNATURE].size() < signatureLen) { + digestInfos[DIGEST_INFO_SIGNATURE].resize(signatureLen); + } if (memcpy_s(digestInfos[DIGEST_INFO_SIGNATURE].data(), signatureLen, buffer, signatureLen) != EOK) { PKG_LOGE("GenerateFileDigest memcpy failed"); return PKG_NONE_MEMORY; -- Gitee From df9a750337e9d6ab4274b18ee3a59bac64322d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 02:58:54 +0000 Subject: [PATCH 20/43] update services/flow_update/update_bin/bin_flow_update.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/flow_update/update_bin/bin_flow_update.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/flow_update/update_bin/bin_flow_update.cpp b/services/flow_update/update_bin/bin_flow_update.cpp index 023448d7..1d288c1d 100644 --- a/services/flow_update/update_bin/bin_flow_update.cpp +++ b/services/flow_update/update_bin/bin_flow_update.cpp @@ -92,7 +92,7 @@ int32_t BinFlowUpdate::StartBinFlowUpdate(uint8_t *data, uint32_t len) bool BinFlowUpdate::AddRemainData(uint8_t *data, uint32_t &len) { if (curlen_ >= maxBufSize_) { - LOG(ERROR) << "curlen_ failed"; + LOG(ERROR) << "curlen_ failed : curlen_ = " << curlen_ << "maxBufSize_ = " << maxBufSize_; return false; } uint32_t copySize = std::min(static_cast(len), static_cast(maxBufSize_ - curlen_)); -- Gitee From ad487ddae144a5975a55180b3750943732c2abf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 03:07:15 +0000 Subject: [PATCH 21/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 80d7334d..a057b2a8 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -574,7 +574,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons "imgBufSize" << imgBufSize; return false; } - if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart -imageBuf), newBuf.data(), editLen) != 0) { + if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart - imageBuf), newBuf.data(), editLen) != 0) { LOG(ERROR) << "memcpy fail. destSize :" << imgBufSize - (ufsLunEntryStart - imageBuf); return false; } -- Gitee From bfbe4984c47c219a0273ddb6698c3aec97eae6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 03:40:28 +0000 Subject: [PATCH 22/43] update services/log/log.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/log/log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/log/log.cpp b/services/log/log.cpp index e231eb84..59603258 100644 --- a/services/log/log.cpp +++ b/services/log/log.cpp @@ -131,7 +131,7 @@ void Logger(int level, const char* fileName, int32_t line, const char* format, . std::vector buff(1024); // 1024 : max length of buff va_list list; va_start(list, format); - int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.size(), buff.size() - 1, format, list); + int size = vsnprintf_s(reinterpret_cast(buff.data()), buff.capacity(), buff.capacity() - 1, format, list); va_end(list); if (size < EOK) { UpdaterLogger(level).OutputUpdaterLog(fileName, line) << "vsnprintf_s failed"; -- Gitee From 3ef8d23c9c242876d0ffba5c6a7c92be3522eb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 08:17:23 +0000 Subject: [PATCH 23/43] update utils/utils.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- utils/utils.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index 981ad9bf..128e866f 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -200,20 +200,19 @@ std::string ConvertSha256Hex(const uint8_t* shaDigest, size_t length) bool SetRebootMisc(const std::string& rebootTarget, const std::string &extData, struct UpdateMessage &msg) { - static const int32_t maxCommandSize = 16; int result = 0; if (rebootTarget == "updater" && strcmp(msg.command, "boot_updater") != 0) { - result = strcpy_s(msg.command, maxCommandSize, "boot_updater"); + result = strcpy_s(msg.command, MAX_COMMAND_SIZE, "boot_updater"); } else if (rebootTarget == "flashd" && strcmp(msg.command, "flashd") != 0) { - result = strcpy_s(msg.command, maxCommandSize, "boot_flash"); + result = strcpy_s(msg.command, MAX_COMMAND_SIZE, "boot_flash"); } else if (rebootTarget == "bootloader" && strcmp(msg.command, "boot_loader") != 0) { - result = strcpy_s(msg.command, maxCommandSize, "boot_loader"); + result = strcpy_s(msg.command, MAX_COMMAND_SIZE, "boot_loader"); } if (result != EOK) { LOG(ERROR) << "reboot set misc strcpy failed"; return false; } - msg.command[maxCommandSize] = 0; + msg.command[MAX_COMMAND_SIZE - 1] = 0; if (extData.empty()) { (void)memset_s(msg.update, sizeof(msg.update), 0, sizeof(msg.update)); return true; -- Gitee From b68e7f2cc322141e19f11afacfef9b328b804fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 08:42:54 +0000 Subject: [PATCH 24/43] update services/diffpatch/diff/blocks_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/blocks_diff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/diffpatch/diff/blocks_diff.cpp b/services/diffpatch/diff/blocks_diff.cpp index 70a8fa8a..b28be3b4 100644 --- a/services/diffpatch/diff/blocks_diff.cpp +++ b/services/diffpatch/diff/blocks_diff.cpp @@ -223,7 +223,7 @@ int32_t BlocksBufferDiff::WritePatchHeader(int64_t controlSize, int64_t diffDataSize, int64_t newSize, size_t &headerLen) { headerLen = std::char_traits::length(BSDIFF_MAGIC) + sizeof(int64_t) + sizeof(int64_t) + sizeof(int64_t); - if (headerLen >= patchData_.size() || offset_ >= (patchData_.size - headerLen)) { + if (headerLen >= patchData_.size() || offset_ >= (patchData_.size() - headerLen)) { PATCH_LOGE("Invalid patch size headerLen = %zu, offset_ = %zu, patchData_.size = %zu", headerLen, offset_, patchData_.size()); return -1; -- Gitee From 245ce5a49908644b01524a18efd239584bbe6565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 08:49:48 +0000 Subject: [PATCH 25/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index a057b2a8..da90e165 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,7 +310,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } - if (TMP_DATA_SIZE <= 2 * deviceBlockSize)) { + if (2 * deviceBlockSize >= TMP_DATA_SIZE)) { LOG(ERROR) << "memcpy_s size fail"; return false; } @@ -569,7 +569,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if ((ufsLunEntryStart - imageBuf) >= imgBufSize){ + if ((ufsLunEntryStart - imageBuf) >= imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart "imgBufSize" << imgBufSize; return false; -- Gitee From b8a8fe7dfad6536be976bd93a1a65b3344acf56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 08:53:12 +0000 Subject: [PATCH 26/43] update services/package/pkg_package/pkg_upgradefile.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/package/pkg_package/pkg_upgradefile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/package/pkg_package/pkg_upgradefile.cpp b/services/package/pkg_package/pkg_upgradefile.cpp index ec8cc565..73af79e6 100644 --- a/services/package/pkg_package/pkg_upgradefile.cpp +++ b/services/package/pkg_package/pkg_upgradefile.cpp @@ -425,7 +425,8 @@ int32_t UpgradePkgFile::ReadPackageInfo(std::vector &signData, size_t & } } - ret = memset_s(buffer.buffer + UPGRADE_RESERVE_LEN, buffer.length - UPGRADE_RESERVE_LEN, 0, GetUpgradeSignatureLen()); + ret = memset_s(buffer.buffer + UPGRADE_RESERVE_LEN, buffer.length - UPGRADE_RESERVE_LEN, + 0, GetUpgradeSignatureLen()); if (ret != EOK) { PKG_LOGE("memset buff fail"); UPDATER_LAST_WORD(PKG_NONE_MEMORY, "memset buff fail"); -- Gitee From 7dc811007f216ca1356614c87027f849a82e5f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 09:14:06 +0000 Subject: [PATCH 27/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index da90e165..709d244c 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,7 +310,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } - if (2 * deviceBlockSize >= TMP_DATA_SIZE)) { + if (2 * deviceBlockSize >= TMP_DATA_SIZE) { LOG(ERROR) << "memcpy_s size fail"; return false; } @@ -571,7 +571,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } if ((ufsLunEntryStart - imageBuf) >= imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart - "imgBufSize" << imgBufSize; + << "imgBufSize" << imgBufSize; return false; } if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart - imageBuf), newBuf.data(), editLen) != 0) { -- Gitee From 4036032bc952a2ad0e7b6f0aa552f325f2ab20f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 09:33:10 +0000 Subject: [PATCH 28/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 709d244c..6788e89b 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -310,10 +310,6 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i ufsPtnDataInfo_.push_back(newLunPtnDataInfo); continue; } - if (2 * deviceBlockSize >= TMP_DATA_SIZE) { - LOG(ERROR) << "memcpy_s size fail"; - return false; - } // for hisi: change ptable.img(512 bytes/block) into format of device(4096 bytes/block) if (memcpy_s(newLunPtnDataInfo.data, TMP_DATA_SIZE, lunStart, imgBlockSize) != EOK) { LOG(WARNING) << "memcpy_s pmbr fail"; -- Gitee From 818717640b86946af13fefc9a35043bbd824a539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:09:09 +0000 Subject: [PATCH 29/43] update services/diffpatch/bzip2/lz4_adapter.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/bzip2/lz4_adapter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/diffpatch/bzip2/lz4_adapter.cpp b/services/diffpatch/bzip2/lz4_adapter.cpp index 21a01933..a3f26ab8 100644 --- a/services/diffpatch/bzip2/lz4_adapter.cpp +++ b/services/diffpatch/bzip2/lz4_adapter.cpp @@ -119,8 +119,8 @@ int32_t Lz4FrameAdapter::WriteData(const BlockBuffer &srcData) return -1; } currDataSize_ += srcData.length; - } else if (currDataSize_ >= inData_.size()) { - PATCH_LOGE("Failed to size "); + } else if (currDataSize_ > inData_.size()) { + PATCH_LOGE("Failed to size currDataSize_ = %zu, inData_.size() = %zu", currDataSize_, inData_.size()); return -1; } else { size_t hasCopyLen = inData_.size() - currDataSize_; -- Gitee From e6b259309960b7e332bc100dce7a26d6d295e6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:14:28 +0000 Subject: [PATCH 30/43] update services/diffpatch/diff/image_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/image_diff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/diffpatch/diff/image_diff.cpp b/services/diffpatch/diff/image_diff.cpp index 6322c745..0dee7953 100644 --- a/services/diffpatch/diff/image_diff.cpp +++ b/services/diffpatch/diff/image_diff.cpp @@ -585,7 +585,7 @@ int32_t CompressedImageDiff::CompressData(Hpackage::PkgManager::FileInfoPtr info outData.resize(IGMDIFF_LIMIT_UNIT * ((start + outSize) / IGMDIFF_LIMIT_UNIT + 1)); } if (memcpy_s(outData.data() + start, outData.size() - start, data.buffer, size) != EOK) { - PATCH_LOGE("Failed to memcpy_s data"); + PATCH_LOGE("Failed to memcpy_s data outData.size() = %zu size = %zu", outData.size(), size); return -1; } return 0; -- Gitee From 9577be2771d0333fbe0d05f267ae42473b454128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:16:58 +0000 Subject: [PATCH 31/43] update services/diffpatch/diff/image_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/image_diff.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/diffpatch/diff/image_diff.cpp b/services/diffpatch/diff/image_diff.cpp index 0dee7953..116ba605 100644 --- a/services/diffpatch/diff/image_diff.cpp +++ b/services/diffpatch/diff/image_diff.cpp @@ -585,7 +585,8 @@ int32_t CompressedImageDiff::CompressData(Hpackage::PkgManager::FileInfoPtr info outData.resize(IGMDIFF_LIMIT_UNIT * ((start + outSize) / IGMDIFF_LIMIT_UNIT + 1)); } if (memcpy_s(outData.data() + start, outData.size() - start, data.buffer, size) != EOK) { - PATCH_LOGE("Failed to memcpy_s data outData.size() = %zu size = %zu", outData.size(), size); + PATCH_LOGE("Failed to memcpy_s data outData.size() = %zu size = %zu start = %zu", + outData.size(), size, start); return -1; } return 0; -- Gitee From bde143073fc804efc21dd3b7d277bf7719748d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:20:04 +0000 Subject: [PATCH 32/43] update services/diffpatch/diff/update_diff.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/diffpatch/diff/update_diff.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/diffpatch/diff/update_diff.cpp b/services/diffpatch/diff/update_diff.cpp index 048e4b5c..4e841b38 100644 --- a/services/diffpatch/diff/update_diff.cpp +++ b/services/diffpatch/diff/update_diff.cpp @@ -112,7 +112,8 @@ int32_t ImageParser::Extract(const std::string &fileName, std::vector & buffer.resize(IGMDIFF_LIMIT_UNIT * ((start + bufferSize) / IGMDIFF_LIMIT_UNIT + 1)); } if (memcpy_s(buffer.data() + start, buffer.size() - start, data.buffer, size) != EOK) { - PATCH_LOGE("Failed to memcpy_s data"); + PATCH_LOGE("Failed to memcpy_s data buffer.size() = %zu size = %zu start = %zu", + buffer.size(), size, start); return -1; } return 0; -- Gitee From 905bde10b17552c786612b1f88fb8a314ab5aca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:31:44 +0000 Subject: [PATCH 33/43] 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 | 3 --- 1 file changed, 3 deletions(-) diff --git a/services/package/pkg_manager/pkg_managerImpl.cpp b/services/package/pkg_manager/pkg_managerImpl.cpp index 7a6bacc0..04f197a6 100644 --- a/services/package/pkg_manager/pkg_managerImpl.cpp +++ b/services/package/pkg_manager/pkg_managerImpl.cpp @@ -861,9 +861,6 @@ int32_t PkgManagerImpl::GenerateFileDigest(PkgStreamPtr stream, if (digestMethod != PKG_DIGEST_TYPE_SHA256) { buffer = buff.buffer + SIGN_SHA256_LEN; } - if (digestInfos[DIGEST_INFO_SIGNATURE].size() < signatureLen) { - digestInfos[DIGEST_INFO_SIGNATURE].resize(signatureLen); - } if (memcpy_s(digestInfos[DIGEST_INFO_SIGNATURE].data(), signatureLen, buffer, signatureLen) != EOK) { PKG_LOGE("GenerateFileDigest memcpy failed"); return PKG_NONE_MEMORY; -- Gitee From 31d102d0d37f960d3f1ff59817ebaf910396ddff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Mon, 25 Aug 2025 12:35:04 +0000 Subject: [PATCH 34/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 6788e89b..7e6210f1 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -565,7 +565,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if ((ufsLunEntryStart - imageBuf) >= imgBufSize) { + if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart << "imgBufSize" << imgBufSize; return false; -- Gitee From 638a275c5ab49ca9d2bb55a2b6f88fd849a8d726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 06:30:40 +0000 Subject: [PATCH 35/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 7e6210f1..4e574cb8 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -565,7 +565,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= imgBufSize) { + if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= (int64_t)imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart << "imgBufSize" << imgBufSize; return false; -- Gitee From 1027e913c4d0f67acfada2d4cd2c63c117080647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 06:37:31 +0000 Subject: [PATCH 36/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 4e574cb8..f05b8c4e 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -565,6 +565,9 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } + if((int64_t)imgBufSize > INT64_MAX) { + LOG(ERROR) << "imgBufSize excel INT64_MAX"; + } if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= (int64_t)imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart << "imgBufSize" << imgBufSize; -- Gitee From 041d01759f08a716687cc95dc49d1f9b01595199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 06:38:48 +0000 Subject: [PATCH 37/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index f05b8c4e..cc0c1bb3 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -565,7 +565,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if((int64_t)imgBufSize > INT64_MAX) { + if ((int64_t)imgBufSize > INT64_MAX) { LOG(ERROR) << "imgBufSize excel INT64_MAX"; } if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= (int64_t)imgBufSize) { -- Gitee From d5d66cc0fb9df89451514c6ceba58e41a6a932a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 06:46:58 +0000 Subject: [PATCH 38/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index cc0c1bb3..c1b51b59 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -565,15 +565,13 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons } std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } - if ((int64_t)imgBufSize > INT64_MAX) { - LOG(ERROR) << "imgBufSize excel INT64_MAX"; - } - if (imageBuf > ufsLunEntryStart || (ufsLunEntryStart - imageBuf) >= (int64_t)imgBufSize) { + uint64_t offset = static_cast(ufsLunEntryStart - imageBuf); + if (imageBuf > ufsLunEntryStart || offset >= (int64_t)imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart << "imgBufSize" << imgBufSize; return false; } - if (memcpy_s(ufsLunEntryStart, imgBufSize - (ufsLunEntryStart - imageBuf), newBuf.data(), editLen) != 0) { + if (memcpy_s(ufsLunEntryStart, imgBufSize - offset, newBuf.data(), editLen) != 0) { LOG(ERROR) << "memcpy fail. destSize :" << imgBufSize - (ufsLunEntryStart - imageBuf); return false; } -- Gitee From f620f3e86b4ec9afbc3c8f348023d0fa7f91c008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 06:47:54 +0000 Subject: [PATCH 39/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index c1b51b59..ded38335 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -566,7 +566,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons std::copy(newEntryBuf.begin(), newEntryBuf.end(), newBuf.begin() + srcInfo[i].gptEntryBufOffset); } uint64_t offset = static_cast(ufsLunEntryStart - imageBuf); - if (imageBuf > ufsLunEntryStart || offset >= (int64_t)imgBufSize) { + if (imageBuf > ufsLunEntryStart || offset >= imgBufSize) { LOG(ERROR) << "memcpy size fail imageBuf" << imageBuf << "ufsLunEntryStart" << ufsLunEntryStart << "imgBufSize" << imgBufSize; return false; -- Gitee From fa69b21fc640217c18f823f9ecfe9764ec59faca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 11:50:38 +0000 Subject: [PATCH 40/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index ded38335..911375c9 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -28,6 +28,8 @@ namespace Updater { constexpr const uint32_t LUN_FOR_SLOT_A = 3; constexpr const uint32_t LUN_FOR_SLOT_B = 4; +constexpr const uint32_t DeviceBlockSize_A = 512; +constexpr const uint32_t DeviceBlockSize_B = 4096; uint32_t UfsPtable::GetDeviceLunNum() { @@ -284,15 +286,16 @@ void UfsPtable::UfsPatchGptHeader(UfsPartitionDataInfo &ptnDataInfo, const uint3 // blocksize is 4096, lbaLen is 512. Because in ptable.img block is 512 while in device block is 4096 bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t imgBufSize) { - if (ptbImgBuffer == nullptr) { + if (ptbImgBuffer == nullptr || (imgBufSize < ptableData_.emmcGptDataLen + ptableData_.imgLuSize + + GetPtableExtraOffset())) { LOG(ERROR) << "input param invalid"; return false; } uint32_t imgBlockSize = ptableData_.lbaLen; // 512 uint32_t deviceBlockSize = GetDeviceBlockSize(); - if (imgBufSize < ptableData_.emmcGptDataLen + ptableData_.imgLuSize + GetPtableExtraOffset()) { - LOG(ERROR) << "input param invalid imgBufSize"; + if(deviceBlockSize != DeviceBlockSize_A && deviceBlockSize != DeviceBlockSize_B) { + LOG(ERROR) << "deviceBlockSize fail:" << deviceBlockSize; return false; } -- Gitee From 37ee1dca2a70d939ba5ffc79d4be3ea76b8e0c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 11:51:44 +0000 Subject: [PATCH 41/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 911375c9..c739403f 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -294,7 +294,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i uint32_t imgBlockSize = ptableData_.lbaLen; // 512 uint32_t deviceBlockSize = GetDeviceBlockSize(); - if(deviceBlockSize != DeviceBlockSize_A && deviceBlockSize != DeviceBlockSize_B) { + if (deviceBlockSize != DeviceBlockSize_A && deviceBlockSize != DeviceBlockSize_B) { LOG(ERROR) << "deviceBlockSize fail:" << deviceBlockSize; return false; } -- Gitee From c9080ba058754a2b6e658382b4a437a97694fbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 12:06:35 +0000 Subject: [PATCH 42/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index c739403f..37b8c0e4 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -28,8 +28,8 @@ namespace Updater { constexpr const uint32_t LUN_FOR_SLOT_A = 3; constexpr const uint32_t LUN_FOR_SLOT_B = 4; -constexpr const uint32_t DeviceBlockSize_A = 512; -constexpr const uint32_t DeviceBlockSize_B = 4096; +constexpr const uint32_t ImgBlockSize = 512; +constexpr const uint32_t DeviceBlockSize = 4096; uint32_t UfsPtable::GetDeviceLunNum() { @@ -294,7 +294,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i uint32_t imgBlockSize = ptableData_.lbaLen; // 512 uint32_t deviceBlockSize = GetDeviceBlockSize(); - if (deviceBlockSize != DeviceBlockSize_A && deviceBlockSize != DeviceBlockSize_B) { + if (deviceBlockSize != ImgBlockSize && deviceBlockSize != DeviceBlockSize) { LOG(ERROR) << "deviceBlockSize fail:" << deviceBlockSize; return false; } -- Gitee From 2cb3f4c4f9fc2875f97ff3efd186ee58b9d79532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=81=E5=87=AF?= Date: Tue, 26 Aug 2025 12:19:48 +0000 Subject: [PATCH 43/43] update services/ptable_parse/ufs_ptable.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 晁凯 --- services/ptable_parse/ufs_ptable.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 37b8c0e4..48466868 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -28,8 +28,8 @@ namespace Updater { constexpr const uint32_t LUN_FOR_SLOT_A = 3; constexpr const uint32_t LUN_FOR_SLOT_B = 4; -constexpr const uint32_t ImgBlockSize = 512; -constexpr const uint32_t DeviceBlockSize = 4096; +constexpr const uint32_t IMG_BLOCK_SIZE = 512; +constexpr const uint32_t DEVICE_BLOCK_SIZE = 4096; uint32_t UfsPtable::GetDeviceLunNum() { @@ -294,7 +294,7 @@ bool UfsPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t i uint32_t imgBlockSize = ptableData_.lbaLen; // 512 uint32_t deviceBlockSize = GetDeviceBlockSize(); - if (deviceBlockSize != ImgBlockSize && deviceBlockSize != DeviceBlockSize) { + if (deviceBlockSize != IMG_BLOCK_SIZE && deviceBlockSize != DEVICE_BLOCK_SIZE) { LOG(ERROR) << "deviceBlockSize fail:" << deviceBlockSize; return false; } -- Gitee