Conversation
…). An MP4 whose audio sample entry type is lpcm with version 0 or 1 aborted the process while parsing the stsd atom. is_pcm_codec() returns true for the lpcm atom type at every version, but pcm_codec_id() only maps fixed PCM atom types and returns CODEC_ID_NULL_AUDIO for lpcm. The version 0 and 1 paths then called bytes_per_pcm_sample() with the null codec id, which fell through to unreachable!(). The PCM format of an lpcm entry is only described by the version 2 extension fields, so an lpcm entry at version 0 or 1 is invalid. The version 0 and 1 arms now reject a null codec id with a decode error, matching the version 2 arm that already guards on it. Fixes pdeljanov#560.
baylesj
approved these changes
Oct 5, 2026
Comment on lines
+220
to
+222
| if entry.codec_id == CODEC_ID_NULL_AUDIO { | ||
| return decode_error("isomp4: lpcm audio sample entry must be version 2"); | ||
| } |
Contributor
There was a problem hiding this comment.
Clean guard matching the v2 CODEC_ID_NULL_AUDIO check below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #560 — an MP4 whose audio sample entry type is
lpcmwith version 0 or 1 aborts the process while parsing thestsdatom.Root cause
is_pcm_codec()(symphonia-format-isomp4/src/atoms/stsd.rs) returnstrueforAtomType::AudioSampleEntryLpcmat every sample entry version, because in version 2 the atom type for PCM data is always LPCM. However,pcm_codec_id()only maps the fixed PCM atom types and returnsCODEC_ID_NULL_AUDIOforlpcm. The version 0 (:216) and version 1 (:249) arms then callbytes_per_pcm_sample(CODEC_ID_NULL_AUDIO), which has no arm for the null codec and falls through tounreachable!()at:381:Reproduced end-to-end: a minimal MP4 (
ftyp+moov/trak/mdia/minf/stbl/stsdwith anlpcmsample entry at version 0) abortsIsoMp4Reader::try_newon current main.Fix
The PCM format of an
lpcmentry is only described by the version 2 extension fields, so anlpcmentry at version 0 or 1 is invalid. Both version arms now rejectCODEC_ID_NULL_AUDIOwith a decode error before reachingbytes_per_pcm_sample, matching the version 2 arm that already guards on the null codec id.Verification
lpcmv0 and v1 sample entries panic atstsd.rs:381(unreachable!()). Fixed: both returnDecodeError("isomp4: lpcm audio sample entry must be version 2").stsd.rs:lpcmv0/v1 rejected,lpcmv2 accepted,sowtv0 accepted (fixed-codec PCM atom types still parse).cargo test -p symphonia-format-isomp4: 4 passed, 0 failed.cargo clippy -p symphonia-format-isomp4 --all-targets: clean;cargo check --all-targets: clean.Disclosure: this PR was prepared with AI assistance (Devin) and verified locally before submission.