diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-05-15 15:08:54 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-05-16 01:22:25 +0200 |
| commit | 6a9d61ef50811ba84656d311fc3713fb1544c505 (patch) | |
| tree | 781dba308c312f5d0e5e4edc6160610931050d14 /src/indexer.c | |
| parent | 73d87a091ca9b5fe4dc236fad6a24149a6fd15a5 (diff) | |
| download | libgit2-6a9d61ef50811ba84656d311fc3713fb1544c505.tar.gz | |
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.
Diffstat (limited to 'src/indexer.c')
| -rw-r--r-- | src/indexer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/indexer.c b/src/indexer.c index ace09af8b..01bec0877 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -441,10 +441,21 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stat git_oid file_hash; 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 (resolve_deltas(idx, stats) < 0) return -1; + if (stats->processed != stats->total) { + giterr_set(GITERR_INDEXER, "Indexing error: early EOF"); + return -1; + } + git_vector_sort(&idx->objects); git_buf_sets(&filename, idx->pack->pack_name); |
