src/backup/fixed_index.rs: improve bound checks inside add_digest
This commit is contained in:
parent
e1225de467
commit
fc14b84937
@ -355,6 +355,10 @@ impl FixedIndexWriter {
|
|||||||
|
|
||||||
pub fn add_digest(&mut self, index: usize, digest: &[u8; 32]) -> Result<(), Error> {
|
pub fn add_digest(&mut self, index: usize, digest: &[u8; 32]) -> Result<(), Error> {
|
||||||
|
|
||||||
|
if index >= self.index_length {
|
||||||
|
bail!("add digest failed - index out of range ({} >= {})", index, self.index_length);
|
||||||
|
}
|
||||||
|
|
||||||
let index_pos = index*32;
|
let index_pos = index*32;
|
||||||
unsafe {
|
unsafe {
|
||||||
let dst = self.index.add(index_pos);
|
let dst = self.index.add(index_pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user