From 66c9c617f322843f487786beac26f3772f1acf1a 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 c5dcd7236e0707..4c69881b64897e 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1385,6 +1385,7 @@ impl Blockstore { shred: &Shred, write_batch: &mut WriteBatch, ) -> Result> { + use crate::shred::SIZE_OF_DATA_SHRED_PAYLOAD; let slot = shred.slot(); let index = u64::from(shred.index()); @@ -1422,7 +1423,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(SIZE_OF_DATA_SHRED_PAYLOAD, shred.data_header.size.into())], )?; data_index.set_present(index, true); let newly_completed_data_sets = update_slot_meta(