From 5a40a45cc54b87c85f61df64ea9518699723325a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Sat, 31 Oct 2009 08:36:26 +0000 Subject: [PATCH] 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 --- taglib/mp4/mp4atom.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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) {