Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 39237:1af95139e5ec
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
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 16 Aug 2018 05:50:49 +0200 |
parents | ed8160e4fea0 |
children | 497effb0a04a |
comparison
equal
deleted
inserted
replaced
39236:362c4603602d | 39237:1af95139e5ec |
---|---|
3375 | 3375 |
3376 if self._eof: | 3376 if self._eof: |
3377 return ''.join(buf) | 3377 return ''.join(buf) |
3378 chunk = self._reader(65536) | 3378 chunk = self._reader(65536) |
3379 self._decompress(chunk) | 3379 self._decompress(chunk) |
3380 if not chunk and not self._pending and not self._eof: | |
3381 # No progress and no new data, bail out | |
3382 return ''.join(buf) | |
3380 | 3383 |
3381 class _GzipCompressedStreamReader(_CompressedStreamReader): | 3384 class _GzipCompressedStreamReader(_CompressedStreamReader): |
3382 def __init__(self, fh): | 3385 def __init__(self, fh): |
3383 super(_GzipCompressedStreamReader, self).__init__(fh) | 3386 super(_GzipCompressedStreamReader, self).__init__(fh) |
3384 self._decompobj = zlib.decompressobj() | 3387 self._decompobj = zlib.decompressobj() |