Skip to content

Commit a5c97b0

Browse files
committed
packfile: fix off-by-one error in decoding logic
shift count being exactly at 7-bit smaller than the long is OK; on 32-bit architecture, shift count starts at 4 and goes through 11, 18 and 25, at which point the guard triggers one iteration too early. Reported-by: Marc Strapetz <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34de5b8 commit a5c97b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
10671067
size = c & 15;
10681068
shift = 4;
10691069
while (c & 0x80) {
1070-
if (len <= used || (bitsizeof(long) - 7) <= shift) {
1070+
if (len <= used || (bitsizeof(long) - 7) < shift) {
10711071
error("bad object header");
10721072
size = used = 0;
10731073
break;

0 commit comments

Comments
 (0)