From 1019b77b8960c905890f80680fdd2333c98da0a8 Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Sun, 1 Nov 2026 23:12:52 +0000 Subject: [PATCH] docs: say what the max_side default is measured against The docstring and the policy table called 9,933 pixels the longest side in the corpus. It is the longest side of an A3 page at 600 dpi, and the corpus's largest page, 39 million pixels at the same resolution, is a little over A4; the default is three times a ceiling the corpus never reaches, not three times a measurement of it. Co-authored-by: Yvette Mankerian Co-Authored-By: Claude Fable 5.1 --- README.md | 2 +- src/sillybos/policy.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bfceeb3..a87b195 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ check(path, Policy(formats={"tiff", "pdf"}, max_pages=50)) | `formats` | jpeg, png, tiff, pdf | the same | What may pass at all. Nothing else is ever allowed, whatever the policy says | | `max_bytes` | 512 MiB | 128 MiB | The file. Checked before anything reads it | | `max_pixels` | 89,478,485 | 50,000,000 | Any one page or frame, decoded. For a PDF page, at `render_dpi`. The default is Pillow's own decompression-bomb threshold, enforced here rather than left to a global | -| `max_side` | 30,000 | 15,000 | Either side of any one page, frame or tile. A pixel budget alone lets through a page a few pixels wide and a million tall, and an abnormally tall image is what drove libtiff's RGBA reader to write colour data to an arbitrary address (CVE-2025-9900). No scanner writes a side longer than a few tens of thousands of pixels; the default is three times the longest side in the corpus (9,933, A3 at 600 dpi) | +| `max_side` | 30,000 | 15,000 | Either side of any one page, frame or tile. A pixel budget alone lets through a page a few pixels wide and a million tall, and an abnormally tall image is what drove libtiff's RGBA reader to write colour data to an arbitrary address (CVE-2025-9900). No scanner writes a side longer than a few tens of thousands of pixels; the default is three times the longest side of an A3 page at 600 dpi (9,933 pixels), and nothing in the corpus comes near it | | `max_pages` | 500 | 100 | Pages of a PDF, frames of a TIFF or animated PNG, pictures of a multi-picture JPEG. Also bounds the header walk itself | | `max_metadata_bytes` | 4 MiB | 1 MiB | The largest block of metadata in an image: a PNG chunk other than image data, a TIFF tag's out-of-line data, a JPEG colour profile across its segments. A scan carries kilobytes; a block the size of the file is where parsers' quadratic paths and allocation flaws live (CVE-2026-96643, CVE-2023-6277) | | `render_dpi` | 200 | 200 | What you will render PDF pages at, so a page's pixels are known before the renderer allocates them | diff --git a/src/sillybos/policy.py b/src/sillybos/policy.py index f9f9ae9..248b866 100644 --- a/src/sillybos/policy.py +++ b/src/sillybos/policy.py @@ -112,8 +112,8 @@ class Policy: drove libtiff's RGBA reader to write colour data to an arbitrary address (CVE-2025-9900). No scanner writes a side longer than a few tens of thousands of pixels: the default is - three times the longest side in the corpus (9,933 pixels, A3 at - 600 dpi). + three times the longest side of an A3 page at 600 dpi (9,933 + pixels), and nothing in the corpus comes near it. max_pages: The most pages in a PDF, or frames in a multi-frame TIFF or animated PNG. Bounds the time and the memory a run takes, and stops the header walk itself on a file with a million