Skip to content

Commit

Permalink
Allow oversized objects in rare cases
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Sep 17, 2024
1 parent 26bd395 commit ac20bad
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shared/network-data-retrieval/src/object_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ impl ObjectFetcher {
}
};

// Return an error if the length is unreasonably large, before we get the next segment
if Self::decode_data_length(&mut data.as_slice(), &mapping)?.is_some() {
// We have enough data to decode the length, and the length is reasonable
if let Ok(data) = Vec::<u8>::decode(&mut data.as_slice()) {
// We have the full object
return Ok(data);
Expand All @@ -351,10 +351,10 @@ impl ObjectFetcher {
if let SegmentItem::BlockContinuation { bytes, .. } = segment_item {
data.extend_from_slice(&bytes);

if Self::decode_data_length(&mut data.as_slice(), &mapping)?.is_some() {
if let Ok(data) = Vec::<u8>::decode(&mut data.as_slice()) {
return Ok(data);
}
// We already downloaded the data, and there are no more segments to download, so
// we don't check the length again. In rare cases this can allow oversized objects
if let Ok(data) = Vec::<u8>::decode(&mut data.as_slice()) {
return Ok(data);
}
}
}
Expand Down

0 comments on commit ac20bad

Please sign in to comment.