Unverified Commit 40ed228b by Edward Thomson Committed by GitHub

Merge pull request #6584 from libgit2/cmn/pack-index-size

pack: cast the number of objects to size_t
parents 72b5c531 1bbe0dd8
...@@ -1268,13 +1268,13 @@ static off64_t nth_packed_object_offset_locked(struct git_pack_file *p, uint32_t ...@@ -1268,13 +1268,13 @@ static off64_t nth_packed_object_offset_locked(struct git_pack_file *p, uint32_t
end = index + p->index_map.len; end = index + p->index_map.len;
index += 4 * 256; index += 4 * 256;
if (p->index_version == 1) if (p->index_version == 1)
return ntohl(*((uint32_t *)(index + (p->oid_size + 4) * n))); return ntohl(*((uint32_t *)(index + (p->oid_size + 4) * (size_t) n)));
index += 8 + p->num_objects * (p->oid_size + 4); index += 8 + (size_t) p->num_objects * (p->oid_size + 4);
off32 = ntohl(*((uint32_t *)(index + 4 * n))); off32 = ntohl(*((uint32_t *)(index + 4 * n)));
if (!(off32 & 0x80000000)) if (!(off32 & 0x80000000))
return off32; return off32;
index += p->num_objects * 4 + (off32 & 0x7fffffff) * 8; index += (size_t) p->num_objects * 4 + (off32 & 0x7fffffff) * 8;
/* Make sure we're not being sent out of bounds */ /* Make sure we're not being sent out of bounds */
if (index >= end - 8) if (index >= end - 8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment