Add tests for SSZ offset attacks

This commit is contained in:
Paul Hauner
2019-05-11 19:09:27 +10:00
parent 8d3ef273a7
commit 1f7b7ec498
2 changed files with 55 additions and 1 deletions

View File

@@ -100,9 +100,14 @@ impl<'a> SszDecoderBuilder<'a> {
fn apply_offsets(&mut self) -> Result<(), DecodeError> {
if !self.offsets.is_empty() {
let mut insertions = 0;
let mut running_offset = self.offsets[0].offset;
if running_offset != self.items_index {
return Err(DecodeError::OutOfBoundsByte { i: running_offset })
}
for i in 1..=self.offsets.len() {
let (slice_option, position) = if i == self.offsets.len() {
(self.bytes.get(running_offset..), self.offsets.len())