diff --git a/binary_sign_tool/hap/sign/src/sign_elf.cpp b/binary_sign_tool/hap/sign/src/sign_elf.cpp index c93feaecf1f2c0713e9e5be5e521f27519fa31fc..3563f5cbba3e7be11b1b7c959a3059fa49a15f50 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"); + 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"); + return false; + } return true; }