Skip to content

Commit 6e8227a

Browse files
ConradIrwinbennetbo
andcommitted
Bounds check for pack index read
Fixes: libgit2#6795 Co-Authored-By: Bennet <[email protected]>
1 parent 8afdad0 commit 6e8227a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libgit2/pack.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,14 @@ static int pack_entry_find_offset(
15251525
if (p->index_version > 1) {
15261526
level1_ofs += 2;
15271527
index += 8;
1528+
1529+
if ((int)short_oid->id[0] + 2 >= p->index_map.len) {
1530+
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->short_oid->[0] out of bounds");
1531+
goto cleanup;
1532+
}
1533+
} else if ((int)short_oid->id[0] >= p->index_map.len) {
1534+
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->short_oid->[0] out of bounds");
1535+
goto cleanup;
15281536
}
15291537

15301538
index += 4 * 256;

0 commit comments

Comments
 (0)