Skip to content

Commit 22f41ab

Browse files
committed
release: nom-exif v3.4.2 (2026-05-20) — PNG streaming fix + MalformedKind plumbing
Patch release covering two fixes: - #55: streaming-mode PNG parsing failed on every real PNG with the confusing "malformed iso-bmff box: PNG: bad signature" error. The chunk walker now requests the correct skip distance and threads PngPastSignature state so the resumed call doesn't re-validate the 8-byte signature against a mid-stream slice. - Error::Malformed.kind is now honest. Previously a hard-coded fallback labelled every parse failure (regardless of which structural unit actually failed) as IsoBmffBox or TiffHeader. The MalformedKind now propagates through ParsingError / ParsedError / LoopAction and surfaces unchanged at the public Error boundary. Adds MalformedKind::PngChunk (the enum is #[non_exhaustive], so additive). No API breakage at the type level; behaviour change is "wrong error label → correct error label" — strict callers matching specific MalformedKind values may see different labels for non-PNG/non-TIFF parse failures.
1 parent 691c2ed commit 22f41ab

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
# Changelog
22

3+
## nom-exif v3.4.2 (2026-05-20)
4+
5+
### Fixed
6+
7+
- **Streaming PNG parsing for files with non-trivial IDAT** — every
8+
real-world PNG (i.e. anything beyond a stripped-down test fixture)
9+
surfaced `malformed iso-bmff box: PNG: bad signature` from
10+
`parse_exif` / `parse_image_metadata`. Root cause was a two-part
11+
bug in the chunk walker: (a) `ClearAndSkip(total - remaining)`
12+
under-requested the skip distance by exactly `cursor + remaining`
13+
bytes — semantically the caller should advance the parser's
14+
logical position by `cursor + total`, not just past the buffer's
15+
end — leaving the parser stranded mid-IDAT; (b) on the resumed call
16+
`extract_chunks` always re-validated `buf[..8]` against the PNG
17+
signature, but the resumed buffer started mid-stream and the check
18+
failed. Fixed both: skip request is now `cursor + total`, and a new
19+
`ParsingState::PngPastSignature` tells the resumed call to skip the
20+
signature check. In-memory mode (`from_memory`) was unaffected
21+
because the full file is buffered at once and `ClearAndSkip` never
22+
fires. Fixes [#55](https://github.com/mindeng/nom-exif/issues/55).
23+
24+
### Fixed (behaviour)
25+
26+
- **`Error::Malformed.kind` correctly identifies the failing
27+
structural unit.** Previously every parse failure that flowed
28+
through `From<ParsedError> for Error` or
29+
`From<nom::Err<...>> for Error` was hard-coded as
30+
`MalformedKind::IsoBmffBox` / `MalformedKind::TiffHeader`
31+
respectively — misleading for PNG / JPEG / EBML inputs. The
32+
`MalformedKind` is now threaded through `ParsingError::Failed`,
33+
`ParsedError::Failed`, and `LoopAction::Failed`, and surfaced
34+
unchanged at the `Error` boundary. Downstream code that
35+
(incorrectly) matched on `kind == IsoBmffBox` to catch *any*
36+
parse failure will need updating; conformant code that uses a
37+
`_ =>` arm (required by `#[non_exhaustive]`) is unaffected.
38+
39+
### Added
40+
41+
- `MalformedKind::PngChunk` variant. `MalformedKind` is
42+
`#[non_exhaustive]`, so adding a variant is non-breaking.
43+
344
## nom-exif v3.4.1 (2026-05-12)
445

546
### Fixed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "nom-exif"
33
rust-version = "1.83"
4-
version = "3.4.1"
4+
version = "3.4.2"
55
edition = "2021"
66
license-file = "LICENSE"
77
description = "Exif/metadata parsing library written in pure Rust, both image (jpeg/heif/heic/jpg/tiff etc.) and video/audio (mov/mp4/3gp/webm/mkv/mka, etc.) files are supported."

0 commit comments

Comments
 (0)