mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 10:37:05 +00:00
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.
This commit is contained in:
parent
73d87a091c
commit
6a9d61ef50
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user