Skip to content

Commit

Permalink
Check size on insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Czabaniuk committed Apr 23, 2021
1 parent 7becc7d commit b685910
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 @@ -1381,6 +1381,7 @@ impl Blockstore {
shred: &Shred,
write_batch: &mut WriteBatch,
) -> Result<Vec<(u32, u32)>> {
use crate::shred::SHRED_PAYLOAD_SIZE;
let slot = shred.slot();
let index = u64::from(shred.index());

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

0 comments on commit b685910

Please sign in to comment.