summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-12-15 23:03:03 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-12-15 23:13:31 +0000
commit93f61c5a9f638e76189cef2dbde7839a9af5ff54 (patch)
tree66d4cd02acf8f8d5a4ecb3a8bb69a0aa0f23ec7b
parent03ea04bfacc601c9d573fabf4c1da3f9f85e148c (diff)
downloadlibgit2-ethomson/zlib.tar.gz
pack: continue zlib while we can make progressethomson/zlib
Continue the zlib stream as long as we can make progress; stop when we stop getting output _or_ when zlib stops taking input from us.
-rw-r--r--src/pack.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pack.c b/src/pack.c
index a9140c63d..30b1464b6 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -908,7 +908,7 @@ static int packfile_unpack_compressed(
do {
size_t bytes = buffer_len - total;
- unsigned int window_len;
+ unsigned int window_len, consumed;
unsigned char *in;
if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) {
@@ -924,10 +924,15 @@ static int packfile_unpack_compressed(
git_mwindow_close(mwindow);
- if (!bytes)
- break;
+ consumed = window_len - (unsigned int)zstream.in_len;
+
+ if (!bytes && !consumed) {
+ git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
+ error = -1;
+ goto out;
+ }
- *position += window_len - zstream.in_len;
+ *position += consumed;
total += bytes;
} while (!git_zstream_eos(&zstream));