Skip to content

Commit b611396

Browse files
jlintongitster
authored andcommitted
packfile: correct zlib buffer handling
The buffer being passed to zlib includes a NUL terminator that git needs to keep in place. unpack_compressed_entry() attempts to detect the case that the source buffer hasn't been fully consumed by checking to see if the destination buffer has been over consumed. This causes a problem, that more recent zlib patches have been poisoning the unconsumed portions of the buffer which overwrites the NUL byte, while correctly returning length and status. Let's place the NUL at the end of the buffer after inflate returns to assure that it doesn't result in problems for git even if its been overwritten by zlib. Signed-off-by: Jeremy Linton <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a42a58d commit b611396

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packfile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,9 @@ static void *unpack_compressed_entry(struct packed_git *p,
14221422
return NULL;
14231423
}
14241424

1425+
/* versions of zlib can clobber unconsumed portion of outbuf */
1426+
buffer[size] = '\0';
1427+
14251428
return buffer;
14261429
}
14271430

0 commit comments

Comments
 (0)