Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Tests/test_file_jpeg2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def test_oversized_box_length() -> None:
data = (
b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a" # JP2 signature box
+ struct.pack(">I4s", 1, b"") # box with 64-bit length
+ struct.pack(">Q", 16 + 2**63) # length beyond the seek range
+ struct.pack(">Q", 2**63 - 12) # length beyond the seek range
)
with pytest.raises(SyntaxError, match="Box length too large"):
Jpeg2KImagePlugin.Jpeg2KImageFile(BytesIO(data))
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/Jpeg2KImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def has_next_box(self) -> bool:
def next_box_type(self) -> bytes:
# Skip the rest of the box if it has not been read
if self.remaining_in_box > 0:
if self.remaining_in_box >= 2**63:
if self.fp.tell() + self.remaining_in_box >= 2**63:
msg = "Box length too large"
raise SyntaxError(msg)
self.fp.seek(self.remaining_in_box, os.SEEK_CUR)
Expand Down
Loading