]> granicus.if.org Git - taglib/commitdiff
Be tolerant of empty FLAC seektable blocks.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 7 Jan 2017 17:11:57 +0000 (02:11 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 9 Jan 2017 15:11:13 +0000 (00:11 +0900)
taglib/flac/flacfile.cpp
tests/data/empty-seektable.flac [new file with mode: 0644]
tests/test_flac.cpp

index b20148860aa9aae5ed6691809303b15a5e1a281e..6b2241034047931962a152e5b40149a47c78e176 100644 (file)
@@ -506,7 +506,9 @@ void FLAC::File::scan()
       return;
     }
 
-    if(blockLength == 0 && blockType != MetadataBlock::Padding) {
+    if(blockLength == 0
+      && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable)
+    {
       debug("FLAC::File::scan() -- Zero-sized metadata block found");
       setValid(false);
       return;
diff --git a/tests/data/empty-seektable.flac b/tests/data/empty-seektable.flac
new file mode 100644 (file)
index 0000000..20dd90d
Binary files /dev/null and b/tests/data/empty-seektable.flac differ
index f2065e09c0ef7f7a6fe6347f49596a20b346d2a7..5bae7d88deb78dd6f5e1ce07ee06e54cc282e826 100644 (file)
@@ -63,6 +63,7 @@ class TestFLAC : public CppUnit::TestFixture
   CPPUNIT_TEST(testEmptyID3v2);
   CPPUNIT_TEST(testStripTags);
   CPPUNIT_TEST(testRemoveXiphField);
+  CPPUNIT_TEST(testEmptySeekTable);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -516,6 +517,24 @@ public:
     }
   }
 
+  void testEmptySeekTable()
+  {
+    ScopedFileCopy copy("empty-seektable", ".flac");
+    {
+      FLAC::File f(copy.fileName().c_str());
+      CPPUNIT_ASSERT(f.isValid());
+      f.xiphComment(true)->setTitle("XiphComment Title");
+      f.save();
+    }
+    {
+      FLAC::File f(copy.fileName().c_str());
+      CPPUNIT_ASSERT(f.isValid());
+      f.seek(42);
+      const ByteVector data = f.readBlock(4);
+      CPPUNIT_ASSERT_EQUAL(ByteVector("\x03\x00\x00\x00", 4), data);
+    }
+  }
+
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);