From 9e8b51d3dabc6985c429de93395064f6c7b3a2d7 Mon Sep 17 00:00:00 2001 From: zfeixiang Date: Sat, 7 Jun 2025 10:47:13 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E9=99=90=E5=88=B6=E5=86=99=E5=85=A5section?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zfeixiang --- binary_sign_tool/hap/sign/src/sign_elf.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/binary_sign_tool/hap/sign/src/sign_elf.cpp b/binary_sign_tool/hap/sign/src/sign_elf.cpp index c93feaec..b12e23a0 100644 --- a/binary_sign_tool/hap/sign/src/sign_elf.cpp +++ b/binary_sign_tool/hap/sign/src/sign_elf.cpp @@ -29,6 +29,7 @@ namespace SignatureTools { int SignElf::blockNum = 0; const std::string SignElf::profileSec = ".profile"; const std::string SignElf::permissionSec = ".permission"; +constexpr size_t MAX_SECTION_SIZE = static_cast(0xFFFFFFFF); bool SignElf::Sign(SignerConfig& signerConfig, std::map& signParams) { @@ -67,6 +68,10 @@ bool SignElf::loadModule(std::map& signParams, std::st SIGNATURE_TOOLS_LOGE("[SignElf] Failed to find module file"); return false; } + if (moduleContent.size() > MAX_SECTION_SIZE) { + SIGNATURE_TOOLS_LOGE("[SignElf] moduleContent size exceeds maximum allowed section size (4GB)"); + return false; + } return true; } @@ -94,6 +99,10 @@ bool SignElf::loadProfileAndSign(SignerConfig& signerConfig, std::map MAX_SECTION_SIZE) { + SIGNATURE_TOOLS_LOGE("[SignElf] profileContent size exceeds maximum allowed section size (4GB)"); + return false; + } return true; } -- Gitee From fc4255cf8743fa6c5a6cf26c61bf16cc3bd78550 Mon Sep 17 00:00:00 2001 From: zfeixiang Date: Mon, 9 Jun 2025 10:02:55 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E9=99=90=E5=88=B6=E5=86=99=E5=85=A5section?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zfeixiang --- binary_sign_tool/hap/sign/src/sign_elf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binary_sign_tool/hap/sign/src/sign_elf.cpp b/binary_sign_tool/hap/sign/src/sign_elf.cpp index b12e23a0..3563f5cb 100644 --- a/binary_sign_tool/hap/sign/src/sign_elf.cpp +++ b/binary_sign_tool/hap/sign/src/sign_elf.cpp @@ -69,7 +69,7 @@ bool SignElf::loadModule(std::map& signParams, std::st return false; } if (moduleContent.size() > MAX_SECTION_SIZE) { - SIGNATURE_TOOLS_LOGE("[SignElf] moduleContent size exceeds maximum allowed section size (4GB)"); + SIGNATURE_TOOLS_LOGE("[SignElf] moduleContent size exceeds maximum allowed section size"); return false; } return true; @@ -100,7 +100,7 @@ bool SignElf::loadProfileAndSign(SignerConfig& signerConfig, std::map MAX_SECTION_SIZE) { - SIGNATURE_TOOLS_LOGE("[SignElf] profileContent size exceeds maximum allowed section size (4GB)"); + SIGNATURE_TOOLS_LOGE("[SignElf] profileContent size exceeds maximum allowed section size"); return false; } return true; -- Gitee