From: Lukáš Lalinský Date: Sat, 31 Oct 2009 08:36:26 +0000 (+0000) Subject: Make sure we are not trying to read a file where MP4 atom header != 8 bytes X-Git-Tag: v1.6.1~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a40a45cc54b87c85f61df64ea9518699723325a;p=taglib Make sure we are not trying to read a file where MP4 atom header != 8 bytes git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1042945 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index ba07409a..25007946 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -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) {