From ef0c9014558c2c021a8a91bc6cd60f1380dedaa9 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 20 Apr 2023 15:45:32 -0400 Subject: [PATCH] Add recent bloat checks added to signer to substrate_signer as well --- processor/src/substrate_signer.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/processor/src/substrate_signer.rs b/processor/src/substrate_signer.rs index e32c2570..248e3cce 100644 --- a/processor/src/substrate_signer.rs +++ b/processor/src/substrate_signer.rs @@ -233,9 +233,14 @@ impl SubstrateSigner { let preprocesses = match preprocesses .drain() .map(|(l, preprocess)| { - machine - .read_preprocess::<&[u8]>(&mut preprocess.as_ref()) - .map(|preprocess| (l, preprocess)) + let mut preprocess_ref = preprocess.as_ref(); + let res = machine + .read_preprocess::<&[u8]>(&mut preprocess_ref) + .map(|preprocess| (l, preprocess)); + if !preprocess_ref.is_empty() { + todo!("malicious signer: extra bytes"); + } + res }) .collect::>() { @@ -283,7 +288,12 @@ impl SubstrateSigner { let shares = match shares .drain() .map(|(l, share)| { - machine.read_share::<&[u8]>(&mut share.as_ref()).map(|share| (l, share)) + let mut share_ref = share.as_ref(); + let res = machine.read_share::<&[u8]>(&mut share_ref).map(|share| (l, share)); + if !share_ref.is_empty() { + todo!("malicious signer: extra bytes"); + } + res }) .collect::>() {