summaryrefslogtreecommitdiff
path: root/src/pack.c
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2017-12-09 05:26:27 +0000
committerlhchavez <lhchavez@lhchavez.com>2017-12-09 05:26:27 +0000
commite7fac2af238ec1eff706d6605985ee5bdfaeb2ea (patch)
tree8bcdbe928fba51aecd01b1f51d6a9fcad661c83b /src/pack.c
parent28662c13a8a36c1145ff3a1796d68422474e31c1 (diff)
downloadlibgit2-e7fac2af238ec1eff706d6605985ee5bdfaeb2ea.tar.gz
Using unsigned instead
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pack.c b/src/pack.c
index 1b88835ec..e0a393817 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -934,18 +934,20 @@ git_off_t get_delta_base(
if (type == GIT_OBJ_OFS_DELTA) {
unsigned used = 0;
unsigned char c = base_info[used++];
- base_offset = c & 127;
+ size_t unsigned_base_offset = c & 127;
while (c & 128) {
if (left <= used)
return GIT_EBUFS;
- base_offset += 1;
- if (!base_offset || MSB(base_offset, 8))
+ unsigned_base_offset += 1;
+ if (!unsigned_base_offset || MSB(unsigned_base_offset, 7))
return 0; /* overflow */
c = base_info[used++];
- base_offset = (base_offset << 7) + (c & 127);
+ unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127);
}
- base_offset = delta_obj_offset - base_offset;
- if (base_offset <= 0 || base_offset >= delta_obj_offset)
+ if ((size_t)delta_obj_offset <= unsigned_base_offset)
+ return 0; /* out of bound */
+ base_offset = delta_obj_offset - unsigned_base_offset;
+ if (base_offset >= delta_obj_offset)
return 0; /* out of bound */
*curpos += used;
} else if (type == GIT_OBJ_REF_DELTA) {