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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [
# TIFF or PDF within our limits (imaging.open_image and check_pdf). Grew
# out of this package; 0.x minor releases are additive, a breaking one
# becomes 1.0 and stops at the ceiling.
"sillybos>=5,<6",
"sillybos>=6,<7",
"python-dotenv>=1.0",
# Writes the searchable PDF. Core rather than an extra because the roadmap
# treats that as the flagship catalogue-ready output, and it should work on
Expand Down
32 changes: 32 additions & 0 deletions tests/ocr/test_input_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,38 @@ def test_a_tiff_whose_tags_contradict_each_other_is_refused(self, tmp_path: Path
open_image(path)


class TestTagData:
def test_a_tiff_whose_tags_all_claim_the_same_bytes_is_refused(self, tmp_path: Path) -> None:
"""sillybos 6 refuses tags that claim more data than the file holds; the reason reaches triage."""
import struct

# One greyscale pixel and a hundred private tags that each claim nearly
# the whole file. A decoder reads every tag's value into memory, so a
# file of a few kilobytes costs it megabytes (CVE-2026-128066).
image = [
(256, 3, 1, 1), # ImageWidth
(257, 3, 1, 1), # ImageLength
(258, 3, 1, 8), # BitsPerSample
(259, 3, 1, 1), # Compression: none
(262, 3, 1, 1), # PhotometricInterpretation: black is zero
(273, 4, 1, 0), # StripOffsets: the pixel is a header byte
(278, 3, 1, 1), # RowsPerStrip
(279, 4, 1, 1), # StripByteCounts
]
claims = 100
size = 8 + 2 + 12 * (len(image) + claims) + 4
entries = image + [(40000 + k, 1, size - 8, 8) for k in range(claims)]
ifd = struct.pack("<H", len(entries))
for tag, kind, count, value in entries:
ifd += struct.pack("<HHII", tag, kind, count, value)
ifd += struct.pack("<I", 0)
path = tmp_path / "overlapping.tif"
path.write_bytes(b"II*\x00" + struct.pack("<I", 8) + ifd)

with pytest.raises(InputRefusedError, match="tags claim more data than it holds"):
open_image(path)


class TestPageSize:
def test_pillows_one_dpi_for_no_resolution_is_not_believed(self) -> None:
image = page()
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading