From 1cf176af61ceb5d125b55aba7fc4798008d5d901 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Wed, 19 Dec 2018 16:41:28 +0100 Subject: Do not ignore non zero RIFF padding if leading to parse error (#882) --- taglib/riff/rifffile.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 0af4d4b4..d3e1aa21 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -325,9 +325,20 @@ void RIFF::File::read() if(offset & 1) { seek(offset); const ByteVector iByte = readBlock(1); - if(iByte.size() == 1 && iByte[0] == '\0') { - chunk.padding = 1; - offset++; + if(iByte.size() == 1) { + bool skipPadding = iByte[0] == '\0'; + if(!skipPadding) { + // Padding byte is not zero, check if it is good to ignore it + const ByteVector fourCcAfterPadding = readBlock(4); + if(isValidChunkName(fourCcAfterPadding)) { + // Use the padding, it is followed by a valid chunk name. + skipPadding = true; + } + } + if(skipPadding) { + chunk.padding = 1; + offset++; + } } } -- cgit v1.2.3