]> granicus.if.org Git - taglib/commitdiff
Do not ignore non zero RIFF padding if leading to parse error (#882)
authorUrs Fleisch <ufleisch@users.sourceforge.net>
Wed, 19 Dec 2018 15:41:28 +0000 (16:41 +0100)
committerUrs Fleisch <ufleisch@users.sourceforge.net>
Sun, 10 Feb 2019 07:40:20 +0000 (08:40 +0100)
taglib/riff/rifffile.cpp

index 0af4d4b4218292f97fcd0ad02509f5c413e223e3..d3e1aa21c4de60a0ce8d5fe53c78e72b2f60da53 100644 (file)
@@ -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++;
+        }
       }
     }