8000 Fix Unpacker max_buffer_length handling by methane · Pull Request #506 · msgpack/msgpack-python · GitHub
[go: up one dir, main page]

Skip to content

Fix Unpacker max_buffer_length handling #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix Unpacker
  • Loading branch information
methane committed May 24, 2022
commit ae4dac4cfd3effa354498c7dc30d55ce7f8f777b
25 changes: 10 additions & 15 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -455,19 +455,13 @@ cdef class Unpacker(object):
cdef object obj
cdef Py_ssize_t prev_head

if self.buf_head >= self.buf_tail and self.file_like is not None:
self.read_from_file()

while 1:
prev_head = self.buf_head
if prev_head >= self.buf_tail:
if iter:
raise StopIteration("No more data to unpack.")
else:
raise OutOfData("No more data to unpack.")

ret = execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head)
self.stream_offset += self.buf_head - prev_head
if prev_head < self.buf_tail:
ret = execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head)
self.stream_offset += self.buf_head - prev_head
else:
ret = 0

if ret == 1:
obj = unpack_data(&self.ctx)
Expand All @@ -477,10 +471,11 @@ cdef class Unpacker(object):
if self.file_like is not None:
self.read_from_file()
continue
if iter:
raise StopIteration("No more data to unpack.")
else:
raise OutOfData("No more data to unpack.")
if prev_head == self.buf_tail:
if iter:
raise StopIteration("No more data to unpack.")
else:
raise OutOfData("No more data to unpack.")
elif ret == -2:
raise FormatError
elif ret == -3:
Expand Down
30AC
0