Skip to content

Commit 40ed228

Browse files
authored
Merge pull request libgit2#6584 from libgit2/cmn/pack-index-size
pack: cast the number of objects to size_t
2 parents 72b5c53 + 1bbe0dd commit 40ed228

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libgit2/pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,13 +1268,13 @@ static off64_t nth_packed_object_offset_locked(struct git_pack_file *p, uint32_t
12681268
end = index + p->index_map.len;
12691269
index += 4 * 256;
12701270
if (p->index_version == 1)
1271-
return ntohl(*((uint32_t *)(index + (p->oid_size + 4) * n)));
1271+
return ntohl(*((uint32_t *)(index + (p->oid_size + 4) * (size_t) n)));
12721272

1273-
index += 8 + p->num_objects * (p->oid_size + 4);
1273+
index += 8 + (size_t) p->num_objects * (p->oid_size + 4);
12741274
off32 = ntohl(*((uint32_t *)(index + 4 * n)));
12751275
if (!(off32 & 0x80000000))
12761276
return off32;
1277-
index += p->num_objects * 4 + (off32 & 0x7fffffff) * 8;
1277+
index += (size_t) p->num_objects * 4 + (off32 & 0x7fffffff) * 8;
12781278

12791279
/* Make sure we're not being sent out of bounds */
12801280
if (index >= end - 8)

0 commit comments

Comments
 (0)