Repository navigation
Conversation
wave_read_header() seeks by sizeof(format) - (8 + format.size) after reading the 16-byte fmt body, which moves backwards when the chunk is longer. A WAVEFORMATEX header (fmt size 18, cbSize = 0) was then rejected; size 40 (WAVE_FORMAT_EXTENSIBLE) only worked because the backward seek lands on the start of the fmt chunk, which is then skipped as an unknown chunk. Seek forward by the remaining chunk bytes, honour the RIFF pad byte of odd-sized chunks, and reject a fmt chunk shorter than 16 bytes.
This branch has not been deployed
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.
wave_read_header()reads the 16-byte PCM part of the fmt chunk and then seeks bysizeof(format) - (8 + format.size)to get past the rest of the chunk. That offset is negative whenever the chunk is longer than 16 bytes, so the reader moves backwards instead of forwards:cbSize = 0), as written by several common tools, is rejected byelc3with "Bad or unsupported WAVE input file".The chunk loop also ignores the RIFF pad byte after an odd-sized chunk, so a file with, e.g., an odd-length
LIST/junkchunk beforedatais rejected too.This change seeks forward by the remaining bytes of the fmt chunk (plus the pad byte when its size is odd), skips the pad byte of odd-sized chunks in the loop, and rejects a fmt chunk shorter than 16 bytes, which the old code would have read past.
Testing (there is no test harness for
tools/, so this was checked by hand): I generated the same 0.1 s 48 kHz mono 16-bit sine as four WAV files: canonical fmt 16, fmt 18 withcbSize = 0, fmt 16 with a 3-byte chunk (plus pad byte) beforedata, and WAVE_FORMAT_EXTENSIBLE (fmt 40). Withelc3 -b 64000:All
.lc3outputs after the change are byte-identical to the canonical fmt 16 output, and the fmt 16 output is unchanged.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.