Skip to content

Commit

Permalink
Add extra checks to avoid infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lessica authored and ianare committed May 2, 2023
1 parent 32e93ce commit 2fee474
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exifread/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def s2n(self, offset, length: int, signed=False) -> int:
raise ValueError('unexpected unpacking length: %d' % length) from err
self.file_handle.seek(self.offset + offset)
buf = self.file_handle.read(length)
if len(buf) != length:
raise ValueError("cannot read enough bytes, something elsewhere is wrong")

if buf:
# https://github.com/ianare/exif-py/pull/158
Expand Down

0 comments on commit 2fee474

Please sign in to comment.