Skip to content

decoder/dsdiff: reject overflowing chunk offsets - #2553

Open
acts-1631 wants to merge 1 commit into
MusicPlayerDaemon:v0.24.xfrom
acts-1631:fix/dsdiff-chunk-overflow
Open

decoder/dsdiff: reject overflowing chunk offsets#2553
acts-1631 wants to merge 1 commit into
MusicPlayerDaemon:v0.24.xfrom
acts-1631:fix/dsdiff-chunk-overflow

Conversation

@acts-1631

Copy link
Copy Markdown
Contributor

dsdiff_read_metadata() reads a 64-bit chunk size from the DFF file and
adds it to the current input offset. If this addition overflows, the
result can point backward. For seekable input, dsdlib_skip_to() then
seeks back to the same chunk header, causing metadata scans to loop
indefinitely. Playback follows the same parsing path and can spin until
stopped.

Use checked offset addition in dsdiff_read_metadata(),
dsdiff_read_prop(), and dsdiff_read_prop_snd(). Also reject overflow
when applying DSDIFF even-byte padding and in dsdlib_skip() relative
seeks. Absolute backward seeks remain supported because the tag reader
uses them intentionally.

Verified with a 28-byte DFF file whose unknown chunk size wraps the
offset from 28 back to 16. The checked calculation now rejects the
chunk.

uint64_t GetPaddedSize() const noexcept {
return (GetSize() + 1) & ~uint64_t(1);
[[nodiscard]]
bool GetPaddedSize(uint64_t &padded_size) const noexcept {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is horribly inelegant code and it's no longer obvious what this function really does. This needs API documentation. But probably it needs a rewrite to make it easier to understand. This whole PR looks like LLM slop.

DSDIFF chunk sizes are read from untrusted files. Adding a size to
the current offset can wrap and seek back to the same chunk header.
Metadata scans then loop forever, while playback spins until stopped.

Reject additions that exceed offset_type before seeking. Also reject
overflow while applying DSDIFF padding and relative skips.
@acts-1631
acts-1631 force-pushed the fix/dsdiff-chunk-overflow branch from 77093d6 to 7b5036d Compare August 2, 2026 13:06
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