Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Check size on insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Czabaniuk committed Apr 22, 2021
1 parent f7e0988 commit 66c9c61
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ impl Blockstore {
shred: &Shred,
write_batch: &mut WriteBatch,
) -> Result<Vec<(u32, u32)>> {
use crate::shred::SIZE_OF_DATA_SHRED_PAYLOAD;
let slot = shred.slot();
let index = u64::from(shred.index());

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 66c9c61

Please sign in to comment.