mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
pack: upcast to size_t for bounds checking
This commit is contained in:
@@ -1499,6 +1499,7 @@ static int pack_entry_find_offset(
|
||||
size_t len)
|
||||
{
|
||||
const uint32_t *level1_ofs;
|
||||
size_t ofs_delta = 0;
|
||||
const unsigned char *index;
|
||||
unsigned hi, lo, stride;
|
||||
int pos, found = 0;
|
||||
@@ -1524,13 +1525,11 @@ static int pack_entry_find_offset(
|
||||
|
||||
if (p->index_version > 1) {
|
||||
level1_ofs += 2;
|
||||
ofs_delta = 2;
|
||||
index += 8;
|
||||
}
|
||||
|
||||
if ((int)short_oid->id[0] + 2 >= p->index_map.len) {
|
||||
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->short_oid->[0] out of bounds");
|
||||
goto cleanup;
|
||||
}
|
||||
} else if ((int)short_oid->id[0] >= p->index_map.len) {
|
||||
if ((size_t)short_oid->id[0] + ofs_delta >= p->index_map.len) {
|
||||
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->short_oid->[0] out of bounds");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user