Skip to content

Commit da6abf5

Browse files
Andreas GalLinus Torvalds
authored andcommitted
[PATCH] fix segfault in fsck-cache
Here is how to trigger it: echo blob 100 > .git/objects/00/ae4e8d3208e09f2cf7a38202a126f728cadb49 Then run fsck-cache. It will try to unpack after the header to calculate the hash, inflate returns total_out == 0 and memcpy() dies. The patch below seems to work with ZLIB 1.1 and 1.2. Signed-off-by: Andreas Gal <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c5b4238 commit da6abf5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sha1_file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned l
155155

156156
inflateInit(&stream);
157157
ret = inflate(&stream, 0);
158+
if (ret < Z_OK)
159+
return NULL;
158160
if (sscanf(buffer, "%10s %lu", type, size) != 2)
159161
return NULL;
160162

0 commit comments

Comments
 (0)