From 1092882f382d51c4199bfe2251da12e1b46607de Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Nov 2020 15:39:18 +0100 Subject: [PATCH] decoder/dsdiff: apply padding to odd-sized chunks Closes https://github.com/MusicPlayerDaemon/MPD/issues/1001 --- NEWS | 2 ++ src/decoder/plugins/DsdiffDecoderPlugin.cxx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ea8a34feb..200998de7 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.22.4 (not yet released) +* decoder + - dsdiff: apply padding to odd-sized chunks ver 0.22.3 (2020/11/06) * playlist diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx index 1fb88da16..5b483514b 100644 --- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx +++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx @@ -55,6 +55,17 @@ struct DsdiffChunkHeader { uint64_t GetSize() const { return size.Read(); } + + /** + * Applies padding to GetSize(), according to the DSDIFF + * specification + * (http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf) + * section 2.3. + */ + [[nodiscard]] constexpr + uint64_t GetPaddedSize() const noexcept { + return (GetSize() + 1) & ~uint64_t(1); + } }; /** struct for DSDIFF native Artist and Title tags */ @@ -117,7 +128,7 @@ dsdiff_read_prop_snd(DecoderClient *client, InputStream &is, return false; offset_type chunk_end_offset = is.GetOffset() - + header.GetSize(); + + header.GetPaddedSize(); if (chunk_end_offset > end_offset) return false;