src/backup/fixed_index.rs: improve bound checks inside add_digest

This commit is contained in:
Dietmar Maurer 2019-05-28 08:47:03 +02:00
parent e1225de467
commit fc14b84937

View File

@ -355,6 +355,10 @@ impl FixedIndexWriter {
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;
unsafe {
let dst = self.index.add(index_pos);