summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorAndreas Gal <gal@uci.edu>2005-04-24 21:04:13 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-24 21:04:13 (GMT)
commitda6abf5d9c342a74dffbcc2015b9c27d7819a900 (patch)
treefc8e8c5906aedbe8b1b99c422b14ae2dbd2220c8 /sha1_file.c
parentc5b423860d4a0f2c1144c578207f327e0985bba7 (diff)
downloadgit-da6abf5d9c342a74dffbcc2015b9c27d7819a900.zip
git-da6abf5d9c342a74dffbcc2015b9c27d7819a900.tar.gz
git-da6abf5d9c342a74dffbcc2015b9c27d7819a900.tar.bz2
[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 <gal@uci.edu> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 97a515a..28ad159 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -155,6 +155,8 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned l
inflateInit(&stream);
ret = inflate(&stream, 0);
+ if (ret < Z_OK)
+ return NULL;
if (sscanf(buffer, "%10s %lu", type, size) != 2)
return NULL;