summaryrefslogtreecommitdiff
path: root/pack-check.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-check.c')
-rw-r--r--pack-check.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/pack-check.c b/pack-check.c
index dad6d8ae7f..4b089fe8ec 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -39,7 +39,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
} while (len);
index_crc = p->index_data;
- index_crc += 2 + 256 + p->num_objects * (the_hash_algo->rawsz/4) + nr;
+ index_crc += 2 + 256 + (size_t)p->num_objects * (the_hash_algo->rawsz/4) + nr;
return data_crc != ntohl(*index_crc);
}
@@ -164,7 +164,7 @@ static int verify_packfile(struct repository *r,
int verify_pack_index(struct packed_git *p)
{
- off_t index_size;
+ size_t len;
const unsigned char *index_base;
git_hash_ctx ctx;
unsigned char hash[GIT_MAX_RAWSZ];
@@ -172,14 +172,14 @@ int verify_pack_index(struct packed_git *p)
if (open_pack_index(p))
return error("packfile %s index not opened", p->pack_name);
- index_size = p->index_size;
index_base = p->index_data;
+ len = p->index_size - the_hash_algo->rawsz;
/* Verify SHA1 sum of the index file */
the_hash_algo->init_fn(&ctx);
- the_hash_algo->update_fn(&ctx, index_base, (unsigned int)(index_size - the_hash_algo->rawsz));
+ the_hash_algo->update_fn(&ctx, index_base, len);
the_hash_algo->final_fn(hash, &ctx);
- if (!hasheq(hash, index_base + index_size - the_hash_algo->rawsz))
+ if (!hasheq(hash, index_base + len))
err = error("Packfile index for %s hash mismatch",
p->pack_name);
return err;