Skip to content

dr_wav: Reject AIFF/AIFC COMM chunks with unsupported bit depths. - #333

Closed
timblechmann wants to merge 1 commit into
mackron:masterfrom
timblechmann:fixes/wav-assertion-in-bswap
Closed

dr_wav: Reject AIFF/AIFC COMM chunks with unsupported bit depths.#333
timblechmann wants to merge 1 commit into
mackron:masterfrom
timblechmann:fixes/wav-assertion-in-bswap

Conversation

@timblechmann

Copy link
Copy Markdown
Contributor

A crafted AIFC COMM chunk can declare a bitsPerSample value that is a multiple of 8 but doesn't correspond to a supported sample byte width (e.g. 40 bits = 5 bytes per sample). This previously went unvalidated and was only discovered deep in the decode path, in drwav__bswap_samples()'s big-endian conversion, which hits DRWAV_ASSERT(DRWAV_FALSE) on unsupported byte widths and aborts the process. Validate bitsPerSample right after AIFF's byte-padding step and reject the file (return DRWAV_FALSE) if it doesn't resolve to one of the supported byte widths (1, 2, 3, 4, 8).

Found by OSS-Fuzz.

A crafted AIFC COMM chunk can declare a bitsPerSample value that is a
multiple of 8 but doesn't correspond to a supported sample byte width
(e.g. 40 bits = 5 bytes per sample). This previously went unvalidated
and was only discovered deep in the decode path, in
drwav__bswap_samples()'s big-endian conversion, which hits
`DRWAV_ASSERT(DRWAV_FALSE)` on unsupported byte widths and aborts the
process. Validate bitsPerSample right after AIFF's byte-padding step
and reject the file (return DRWAV_FALSE) if it doesn't resolve to one
of the supported byte widths (1, 2, 3, 4, 8).

Found by OSS-Fuzz.
@timblechmann

Copy link
Copy Markdown
Contributor Author

@mackron

mackron commented Aug 31, 2026

Copy link
Copy Markdown
Owner

This is invalid. There is a function called drwav_read_raw() which is used as a low-level way to read raw audio data from the data chunk, regardless of format. It probably needs to be checked at the drwav_read_pcm_frames() level. Will leave this open to remind me to fix it when I get a chance.

mackron added a commit that referenced this pull request Aug 31, 2026
@mackron

mackron commented Aug 31, 2026

Copy link
Copy Markdown
Owner

This should be fixed in the master branch.

@mackron mackron closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants