diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-08-02 14:06:43 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-02 14:06:43 -0700 |
commit | 9bcdaab13ea542bbdb4ea4d5f189ca00b9270887 (patch) | |
tree | 31ac4bde579190e5cada2213d854a5206c128fd7 | |
parent | Merge branch 'jt/bulk-prefetch' (diff) | |
parent | pack-bitmap: check pack validity when opening bitmap (diff) | |
download | tgif-9bcdaab13ea542bbdb4ea4d5f189ca00b9270887.tar.xz |
Merge branch 'jk/check-pack-valid-before-opening-bitmap'
A race between repacking and using pack bitmaps has been corrected.
* jk/check-pack-valid-before-opening-bitmap:
pack-bitmap: check pack validity when opening bitmap
-rw-r--r-- | pack-bitmap.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c index c8cb9ef13b..d999616c9e 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -298,6 +298,11 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git return -1; } + if (!is_pack_valid(packfile)) { + close(fd); + return -1; + } + bitmap_git->pack = packfile; bitmap_git->map_size = xsize_t(st.st_size); bitmap_git->map = xmmap(NULL, bitmap_git->map_size, PROT_READ, MAP_PRIVATE, fd, 0); |