The daemon is responsible for verifying the index before putting it in the shared memory. No need to redo it again. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- read-cache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/read-cache.c b/read-cache.c index 4041485..e98521f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1332,6 +1332,8 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size) hdr_version = ntohl(hdr->hdr_version); if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version) return error("bad index version %d", hdr_version); + if (!size) + return 0; git_SHA1_Init(&c); git_SHA1_Update(&c, hdr, size - 20); git_SHA1_Final(sha1, &c); @@ -1511,7 +1513,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) struct stat st; unsigned long src_offset; struct cache_header *hdr; - void *mmap; + void *mmap, *old_mmap; size_t mmap_size; struct strbuf previous_name_buf = STRBUF_INIT, *previous_name; @@ -1543,9 +1545,10 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) } close(fd); + old_mmap = mmap; mmap = try_shm(mmap, &mmap_size); hdr = mmap; - if (verify_hdr(hdr, mmap_size) < 0) + if (verify_hdr(hdr, old_mmap != mmap ? 0 : mmap_size) < 0) goto unmap; hashcpy(istate->sha1, (const unsigned char *)hdr + mmap_size - 20); -- 1.9.1.346.ga2b5940 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html