diff options
author | Max Kellermann <max@musicpd.org> | 2020-11-10 15:39:18 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-11-10 15:55:33 +0100 |
commit | 1092882f382d51c4199bfe2251da12e1b46607de (patch) | |
tree | 152bb4bb4c5c9d5e7228851d1bfd070f1d175ad4 /src | |
parent | 8a7986c3bf13415790932cf1f27c3a1f8144a01a (diff) |
decoder/dsdiff: apply padding to odd-sized chunks
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1001
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/DsdiffDecoderPlugin.cxx | 13 |
1 files changed, 12 insertions, 1 deletions
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; |