patches bug in data-shred index sanitize (#24707)
https://github.com/solana-labs/solana/pull/24653 introduced an off-by-one error in data-shred index sanitize.
This commit is contained in:
parent
7de339cb5c
commit
913ad79cd9
|
@ -519,7 +519,7 @@ impl Shred {
|
||||||
}
|
}
|
||||||
match self.shred_type() {
|
match self.shred_type() {
|
||||||
ShredType::Data => {
|
ShredType::Data => {
|
||||||
if self.index() as usize > MAX_DATA_SHREDS_PER_SLOT {
|
if self.index() as usize >= MAX_DATA_SHREDS_PER_SLOT {
|
||||||
return Err(Error::InvalidDataShredIndex {
|
return Err(Error::InvalidDataShredIndex {
|
||||||
index: self.index(),
|
index: self.index(),
|
||||||
});
|
});
|
||||||
|
@ -2136,6 +2136,14 @@ mod tests {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
let mut shred = shred.clone();
|
||||||
|
shred.common_header.index = MAX_DATA_SHREDS_PER_SLOT as u32;
|
||||||
|
assert_matches!(
|
||||||
|
shred.sanitize(),
|
||||||
|
Err(Error::InvalidDataShredIndex { index: 32768 })
|
||||||
|
);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
shred.data_header.size = shred.payload().len() as u16 + 1;
|
shred.data_header.size = shred.payload().len() as u16 + 1;
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
|
|
Loading…
Reference in New Issue