tEnsure block pointer in the index file is within limits - dedup - deduplicating backup program
(HTM) git clone git://git.z3bra.org/dedup.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit c0f3292de8c30657c13d7564a0655e65df8e0459
(DIR) parent bf3abd9cb6cf698a89cddc3fbd635cf6d6bed45c
(HTM) Author: sin <sin@2f30.org>
Date: Wed, 21 Mar 2018 11:12:19 +0000
Ensure block pointer in the index file is within limits
Diffstat:
M dedup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/dedup.c b/dedup.c
t@@ -267,6 +267,8 @@ extract(unsigned char *id, int fd)
for (j = 0; j < ent->nblks; j++) {
struct blk blk;
+ if (ent->blks[j] > nblks())
+ errx(1, "index is corrupted");
read_blk(&blk, ent->blks[j]);
xwrite(1, blk.data, blk.sz);
}
t@@ -327,8 +329,8 @@ check(void)
for (j = 0; j < ent->nblks; j++) {
struct blk blk;
- /* XXX: If there's file corruption, ent->blks[j]
- * could point anywhere */
+ if (ent->blks[j] > nblks())
+ errx(1, "index is corrupted");
read_blk(&blk, ent->blks[j]);
SHA256_Update(&ctx, blk.data, blk.sz);
}