diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2018-12-19 16:41:28 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2019-02-10 08:40:20 +0100 |
commit | 1cf176af61ceb5d125b55aba7fc4798008d5d901 (patch) | |
tree | e2b917380ba1d15c91e60161279309b0b4a9aaf7 | |
parent | 5cb589a5b82c13ba8f0542e5e79629da7645cb3c (diff) |
Do not ignore non zero RIFF padding if leading to parse error (#882)
-rw-r--r-- | taglib/riff/rifffile.cpp | 17 |
1 files 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++; + } } } |