From 4abcb08cc9227095717d33e5466eda5f243b22aa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 19 Feb 2016 17:31:20 +0100 Subject: [PATCH] tag/{aiff,riff}: fix ID3 chunk padding Apply padding only to the fseek(), not to the chunk size. This fixes bogus "failed to read riff chunk" messages when the last chunk has an odd size. See http://bugs.musicpd.org/view.php?id=4486 --- NEWS | 2 ++ src/tag/Aiff.cxx | 8 ++++---- src/tag/Riff.cxx | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index c988ac320..26ecdc4e9 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.19.13 (not yet released) +* tags + - aiff, riff: fix ID3 chunk padding ver 0.19.12 (2015/12/15) * fix assertion failure on malformed UTF-8 tag diff --git a/src/tag/Aiff.cxx b/src/tag/Aiff.cxx index c2498c9e9..3c0d138d7 100644 --- a/src/tag/Aiff.cxx +++ b/src/tag/Aiff.cxx @@ -84,14 +84,14 @@ aiff_seek_id3(FILE *file) underflow when casting to off_t */ return 0; - if (size % 2 != 0) - /* pad byte */ - ++size; - if (memcmp(chunk.id, "ID3 ", 4) == 0) /* found it! */ return size; + if (size % 2 != 0) + /* pad byte */ + ++size; + if (fseek(file, size, SEEK_CUR) != 0) return 0; } diff --git a/src/tag/Riff.cxx b/src/tag/Riff.cxx index c630f082d..19bc3b817 100644 --- a/src/tag/Riff.cxx +++ b/src/tag/Riff.cxx @@ -82,15 +82,15 @@ riff_seek_id3(FILE *file) underflow when casting to off_t */ return 0; - if (size % 2 != 0) - /* pad byte */ - ++size; - if (memcmp(chunk.id, "id3 ", 4) == 0 || memcmp(chunk.id, "ID3 ", 4) == 0) /* found it! */ return size; + if (size % 2 != 0) + /* pad byte */ + ++size; + if (fseek(file, size, SEEK_CUR) != 0) return 0; }