# HG changeset patch # User Joerg Sonnenberger # Date 2018-08-16 03:50:49 # Node ID 1af95139e5ecf70ddf585776774e4531cf340838 # Parent 362c4603602dc504c174862ce3bedde6e786a302 util: improve handling of truncated compressed streams If the compressed stream is over as marked by the reader providing nothing new and the compression engine is not providing data, bail out. This can happen in practise when the server misbehaves and would result in an infinite loop otherwise. Differential Revision: https://phab.mercurial-scm.org/D4297 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3377,6 +3377,9 @@ class _CompressedStreamReader(object): return ''.join(buf) chunk = self._reader(65536) self._decompress(chunk) + if not chunk and not self._pending and not self._eof: + # No progress and no new data, bail out + return ''.join(buf) class _GzipCompressedStreamReader(_CompressedStreamReader): def __init__(self, fh):