From 8f183407bb57bacc6d91668adc124259788e441f Mon Sep 17 00:00:00 2001 From: Iceomatic <89707822+iceomatic@users.noreply.github.com> Date: Sun, 13 Oct 2024 19:17:30 +0200 Subject: [PATCH] add: num_signatures == 0 check from SIMD-0152 --- sdk/src/ed25519_instruction.rs | 1 + sdk/src/secp256r1_instruction.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/src/ed25519_instruction.rs b/sdk/src/ed25519_instruction.rs index 45a8f1c2c2d932..a7bae6b4164a32 100644 --- a/sdk/src/ed25519_instruction.rs +++ b/sdk/src/ed25519_instruction.rs @@ -93,6 +93,7 @@ pub fn verify( return Err(PrecompileError::InvalidInstructionDataSize); } let num_signatures = data[0] as usize; + if num_signatures == 0 && data.len() > SIGNATURE_OFFSETS_START { return Err(PrecompileError::InvalidInstructionDataSize); } diff --git a/sdk/src/secp256r1_instruction.rs b/sdk/src/secp256r1_instruction.rs index 545cf52963759c..ca2e6a3e0313c6 100644 --- a/sdk/src/secp256r1_instruction.rs +++ b/sdk/src/secp256r1_instruction.rs @@ -142,7 +142,9 @@ pub fn verify( return Err(PrecompileError::InvalidInstructionDataSize); } let num_signatures = data[0] as usize; - + if num_signatures == 0 { + return Err(PrecompileError::InvalidInstructionDataSize); + } if num_signatures > 8 { return Err(PrecompileError::InvalidInstructionDataSize); }