Commit Graph
3 Commits
Author SHA1 Message Date
Alex Chambers ed70d09162 craft-heif: a protected Exif or XMP item is unreadable, not absent
A nonzero protection index made `item_info` return before it read the
item type, so a protected `Exif` or XMP item vanished: `scan` was
complete and empty, as if the file held no metadata. The protection
index doesn't hide the type, so read it, and return the item from
`scan` as `Unreadable::Protected`. `read` still leaves it out.
2026-11-15 00:28:28 +01:00
Alex Chambers 7ad164ff8a craft-heif: refuse a too-large item before copying any of it
`Iloc::gather` copied extents until it passed its limit and then
returned `TooLarge`, and `scan` charges its byte budget only for items
it returns. So 1,024 items, each naming one 64 KiB region 257 times,
copied 16 GiB from a 2 MiB file, and `read` up to 1 GiB.

Check every extent and sum the lengths first, and copy only when the
total fits. The new test counts the bytes copied over the full
1,024-gather scan and `read`'s 64 candidates; it copied 16 GiB before.
2026-11-15 00:26:42 +01:00
Alex Chambers 76ddfc3749 craft-heif: items reads the primary image's metadata; add scan and exif_tiff
Port the container reader of storytold/lightcraft#1208 into `items`:

- `read` follows `pitm`, `cdsc` and the `dimg` inputs to return the
  primary image's EXIF and XMP, then items tied to no image. A
  thumbnail's or depth map's metadata is no longer the photo's.
- `scan` returns every EXIF and XMP item, with each item's bytes or why
  they can't be read, and `Scan::complete` is false when the item
  catalog can't be read in full. An app that must prove a file has no
  location refuses when unsure.
- `exif_tiff` finds the TIFF stream with or without a correct offset
  field or an `Exif\0\0` prefix.
- `iloc` is walked once; the module denies indexing and unchecked
  arithmetic; boxes, items and gathered bytes are bounded.

The tests of #1055 and lightcraft#1208 come along, adapted to assert
the returned bytes and the scan's completeness.
2026-11-14 21:57:59 +01:00