From b6859107f458ad1a2799816da546762b43104b4a Mon Sep 17 00:00:00 2001 From: Steven Czabaniuk Date: Thu, 22 Apr 2021 11:06:28 -0500 Subject: [PATCH] Check size on insertion --- ledger/src/blockstore.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 016c6d7f962b9d..732ef7fcc19455 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1381,6 +1381,7 @@ impl Blockstore { shred: &Shred, write_batch: &mut WriteBatch, ) -> Result> { + use crate::shred::SHRED_PAYLOAD_SIZE; let slot = shred.slot(); let index = u64::from(shred.index()); @@ -1418,7 +1419,7 @@ impl Blockstore { (slot, index), // Payload will be padded out to SHRED_PAYLOAD_SIZE // But only need to store the bytes within data_header.size - &shred.payload[..shred.data_header.size as usize], + &shred.payload[..cmp::min(SHRED_PAYLOAD_SIZE, shred.data_header.size.into())], )?; data_index.set_present(index, true); let newly_completed_data_sets = update_slot_meta(