Skip to content

Commit e7fac2a

Browse files
committed
Using unsigned instead
1 parent 28662c1 commit e7fac2a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/pack.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,18 +934,20 @@ git_off_t get_delta_base(
934934
if (type == GIT_OBJ_OFS_DELTA) {
935935
unsigned used = 0;
936936
unsigned char c = base_info[used++];
937-
base_offset = c & 127;
937+
size_t unsigned_base_offset = c & 127;
938938
while (c & 128) {
939939
if (left <= used)
940940
return GIT_EBUFS;
941-
base_offset += 1;
942-
if (!base_offset || MSB(base_offset, 8))
941+
unsigned_base_offset += 1;
942+
if (!unsigned_base_offset || MSB(unsigned_base_offset, 7))
943943
return 0; /* overflow */
944944
c = base_info[used++];
945-
base_offset = (base_offset << 7) + (c & 127);
945+
unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127);
946946
}
947-
base_offset = delta_obj_offset - base_offset;
948-
if (base_offset <= 0 || base_offset >= delta_obj_offset)
947+
if ((size_t)delta_obj_offset <= unsigned_base_offset)
948+
return 0; /* out of bound */
949+
base_offset = delta_obj_offset - unsigned_base_offset;
950+
if (base_offset >= delta_obj_offset)
949951
return 0; /* out of bound */
950952
*curpos += used;
951953
} else if (type == GIT_OBJ_REF_DELTA) {

0 commit comments

Comments
 (0)