aboutsummaryrefslogtreecommitdiffstats
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2023-04-17 16:21:41 +0000
committerJunio C Hamano <gitster@pobox.com>2023-04-17 14:39:05 -0700
commit5a6072f631dcf4d9f65e83b08d14c82e2af45dd8 (patch)
tree4868d4798a2d84684f77a1c09788876db317bf79 /pack-bitmap.c
parent5f658d1b577722111564f51962d6af33d1fe96c6 (diff)
downloadgit-5a6072f631dcf4d9f65e83b08d14c82e2af45dd8.tar.gz
fsck: validate .rev file header
While parsing a .rev file, we check the header information to be sure it makes sense. This happens before doing any additional validation such as a checksum or value check. In order to differentiate between a bad header and a non-existent file, we need to update the API for loading a reverse index. Make load_pack_revindex_from_disk() non-static and specify that a positive value means "the file does not exist" while other errors during parsing are negative values. Since an invalid header prevents setting up the structures we would use for further validations, we can stop at that point. The place where we can distinguish between a missing file and a corrupt file is inside load_revindex_from_disk(), which is used both by pack rev-indexes and multi-pack-index rev-indexes. Some tests in t5326 demonstrate that it is critical to take some conditions to allow positive error signals. Add tests that check the three header values. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 38b35c4823..3828aab612 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -379,7 +379,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
goto cleanup;
}
- if (load_midx_revindex(bitmap_git->midx) < 0) {
+ if (load_midx_revindex(bitmap_git->midx)) {
warning(_("multi-pack bitmap is missing required reverse index"));
goto cleanup;
}
@@ -2140,7 +2140,7 @@ uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
if (!bitmap_is_midx(bitmap_git))
load_reverse_index(r, bitmap_git);
- else if (load_midx_revindex(bitmap_git->midx) < 0)
+ else if (load_midx_revindex(bitmap_git->midx))
BUG("rebuild_existing_bitmaps: missing required rev-cache "
"extension");