From a95a3fb8939efaa7c07e3836d71ba14e0a3c8a0b Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 4 Jun 2020 10:12:10 +0200 Subject: [PATCH] fix csum calculation of not 'chunk_size' aligned images the last chunk does not have to be as big as the chunk_size, just use the already available 'chunk_end' function which does the correct thing this fixes restoration of images whose sizes are not a multiple of 'chunk_size' as well Signed-off-by: Dominik Csapak --- src/backup/fixed_index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index f21b2d03..23a7f03d 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -198,7 +198,7 @@ impl FixedIndexReader { let mut csum = openssl::sha::Sha256::new(); let mut chunk_end = 0; for pos in 0..self.index_length { - chunk_end = ((pos + 1) * self.chunk_size) as u64; + chunk_end = self.chunk_end(pos); let digest = self.chunk_digest(pos); csum.update(digest); }