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.
`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.
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.