]> granicus.if.org Git - taglib/commitdiff
Make sure we are not trying to read a file where MP4 atom header != 8 bytes
authorLukáš Lalinský <lalinsky@gmail.com>
Sat, 31 Oct 2009 08:36:26 +0000 (08:36 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Sat, 31 Oct 2009 08:36:26 +0000 (08:36 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1042945 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/mp4/mp4atom.cpp

index ba07409a39593f20e264bd1a3a91a46c4b36c14f..25007946b3d0fbc4c7c7954b00fa064d6009c3b6 100644 (file)
@@ -44,6 +44,15 @@ MP4::Atom::Atom(File *file)
 {
   offset = file->tell();
   ByteVector header = file->readBlock(8);
+  if (header.size() != 8) {
+    // The atom header must be 8 bytes long, otherwise there is either
+    // trailing garbage or the file is truncated
+    debug("MP4: Expected 8 bytes of atom header");
+    length = 0;
+    file->seek(0, File::End);
+    return;
+  }
+
   length = header.mid(0, 4).toUInt();
 
   if (length == 1) {