Fix for misleading "missing delta bases" error - Fix #2721.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/src/indexer.c b/src/indexer.c
index 0e682dd..8127ff8 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -671,8 +671,10 @@ static int inject_object(git_indexer *idx, git_oid *id)
seek_back_trailer(idx);
entry_start = idx->pack->mwf.size;
- if (git_odb_read(&obj, idx->odb, id) < 0)
+ if (git_odb_read(&obj, idx->odb, id) < 0) {
+ giterr_set(GITERR_INDEXER, "missing delta bases");
return -1;
+ }
data = git_odb_object_data(obj);
len = git_odb_object_size(obj);
@@ -827,7 +829,6 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
break;
if (!progressed && (fix_thin_pack(idx, stats) < 0)) {
- giterr_set(GITERR_INDEXER, "missing delta bases");
return -1;
}
}
diff --git a/src/pack.c b/src/pack.c
index 7903238..df25631 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -408,11 +408,14 @@ static int packfile_unpack_header1(
size = c & 15;
shift = 4;
while (c & 0x80) {
- if (len <= used)
+ if (len <= used) {
+ giterr_set(GITERR_ODB, "buffer too small");
return GIT_EBUFS;
+ }
if (bitsizeof(long) <= shift) {
*usedp = 0;
+ giterr_set(GITERR_ODB, "packfile corrupted");
return -1;
}