From fc14b849379ec0dd03784dbdb3bb862acd7e659b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 28 May 2019 08:47:03 +0200 Subject: [PATCH] src/backup/fixed_index.rs: improve bound checks inside add_digest --- src/backup/fixed_index.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index 0e99af8d..8f664d7f 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -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);