From f85bd24078a954f1cec89d983e97776b126b96e4 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 22 Jan 2020 09:05:26 +0100 Subject: [PATCH] Fix wrong detection of zlib inflate error, which could result in infinite looping in readfile --- src/utils/readfile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/readfile.cpp b/src/utils/readfile.cpp index bd2b0cac..754e6971 100644 --- a/src/utils/readfile.cpp +++ b/src/utils/readfile.cpp @@ -229,7 +229,10 @@ public: while (m_stream.avail_in != 0) { m_stream.next_out = (Bytef*)m_obuf; m_stream.avail_out = m_obs; - if ((error = inflate(&m_stream, Z_SYNC_FLUSH)) < Z_OK) { + if ((error = inflate(&m_stream, Z_SYNC_FLUSH)) != Z_OK) { + // Note that Z_STREAM_END is also an error here, + // because we still have data: something is wrong with + // the file. LOGERR("inflate error: " << error << endl); if (reason) { *reason += " Zlib inflate failed";