dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit c0f3292de8c30657c13d7564a0655e65df8e0459
parent bf3abd9cb6cf698a89cddc3fbd635cf6d6bed45c
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:
Mdedup.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -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); } @@ -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); }