Fix Unpacker max_buffer_length handling (#506)

This commit is contained in:
Inada Naoki 2022-05-24 19:46:51 +09:00 committed by GitHub
parent b75e3412fb
commit 500a238028
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 17 deletions

View file

@ -423,6 +423,8 @@ class Unpacker(object):
# Read from file
remain_bytes = -remain_bytes
if remain_bytes + len(self._buffer) > self._max_buffer_size:
raise BufferFull
while remain_bytes > 0:
to_read_bytes = max(self._read_size, remain_bytes)
read_data = self.file_like.read(to_read_bytes)