Bypass input stream buffer overruns

This fixes crashes that could otherwise happen when receiving animated
stickers.
This commit is contained in:
Andrew Ferrazzutti 2021-05-04 03:09:24 -04:00
parent d080590c54
commit 6a9d625d69
1 changed files with 8 additions and 1 deletions

View File

@ -147,7 +147,14 @@ class RPCClient:
async def _read_loop(self) -> None:
while self._reader is not None and not self._reader.at_eof():
line = await self._reader.readline()
line = b''
while True:
try:
line += await self._reader.readuntil()
break
except asyncio.exceptions.LimitOverrunError as e:
self.log.warning(f"Buffer overrun: {e}")
line += await self._reader.read(self._reader._limit)
if not line:
continue
try: