Commit 6bd024aacd8bb5a8cbe16418b776917dbd40e275

Edward Thomson 2022-06-11T15:38:33

Merge pull request #6309 from ccstolley/ccs_fix_midx_offset midx: fix large offset table check.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/libgit2/midx.c b/src/libgit2/midx.c
index d4e53c4..98e661c 100644
--- a/src/libgit2/midx.c
+++ b/src/libgit2/midx.c
@@ -431,8 +431,8 @@ int git_midx_entry_find(
 
 	object_offset = idx->object_offsets + pos * 8;
 	offset = ntohl(*((uint32_t *)(object_offset + 4)));
-	if (offset & 0x80000000) {
-		uint32_t object_large_offsets_pos = offset & 0x7fffffff;
+	if (idx->object_large_offsets && offset & 0x80000000) {
+		uint32_t object_large_offsets_pos = (uint32_t) (offset ^ 0x80000000);
 		const unsigned char *object_large_offsets_index = idx->object_large_offsets;
 
 		/* Make sure we're not being sent out of bounds */