Commit 6a9d61ef by Carlos Martín Nieto

indexer: add more consistency checks

Error out in finalize if there is junk after the packfile hash or we
couldn't process all the objects.
parent 73d87a09
...@@ -441,10 +441,21 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stat ...@@ -441,10 +441,21 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stat
git_oid file_hash; git_oid file_hash;
SHA_CTX ctx; SHA_CTX ctx;
/* Test for this before resolve_deltas(), as it plays with idx->off */
if (idx->off < idx->pack->mwf.size - GIT_OID_RAWSZ) {
giterr_set(GITERR_INDEXER, "Indexing error: junk at the end of the pack");
return -1;
}
if (idx->deltas.length > 0) if (idx->deltas.length > 0)
if (resolve_deltas(idx, stats) < 0) if (resolve_deltas(idx, stats) < 0)
return -1; return -1;
if (stats->processed != stats->total) {
giterr_set(GITERR_INDEXER, "Indexing error: early EOF");
return -1;
}
git_vector_sort(&idx->objects); git_vector_sort(&idx->objects);
git_buf_sets(&filename, idx->pack->pack_name); git_buf_sets(&filename, idx->pack->pack_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment