mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-02 10:03:28 +00:00
p2p-block: check for out-of-bounds indexing (#2187)
Return err on index OOB instead of panicking
This commit is contained in:
parent
cea93c444e
commit
fdf1c18dd6
|
@ -204,9 +204,12 @@ where
|
|||
|
||||
file.write_all(&data_buf[..block.size as usize]).await?;
|
||||
|
||||
let req = self.reqs.requests.get(self.i).ok_or_else(|| {
|
||||
debug!("Vector read out of bounds!");
|
||||
io::ErrorKind::Other
|
||||
})?;
|
||||
// TODO: Should this be `read == 0`
|
||||
// TODO: Out of range protection on indexed access
|
||||
if offset == self.reqs.requests[self.i].size {
|
||||
if offset == req.size {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue