aboutsummaryrefslogtreecommitdiffstats
path: root/taglib/mp4
diff options
context:
space:
mode:
authorTsuda Kageyu <tsuda.kageyu@gmail.com>2016-11-02 15:44:50 +0900
committerTsuda Kageyu <tsuda.kageyu@gmail.com>2016-11-02 15:44:50 +0900
commitf5ca097379b270d1f92368e283d30f8703161645 (patch)
tree6fe5f10a5153f92505d788e024bc22fdbdf30669 /taglib/mp4
parenteb6d058ab93ffcfbe00878a3aba6ffc1ac7d3df6 (diff)
Proper handling of MP4 atoms with zero length.
If the size of an atom is 0, it designates the last atom which extends to the end of the file.
Diffstat (limited to 'taglib/mp4')
-rw-r--r--taglib/mp4/mp4atom.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp
index 5758173b..20709212 100644
--- a/taglib/mp4/mp4atom.cpp
+++ b/taglib/mp4/mp4atom.cpp
@@ -54,10 +54,15 @@ MP4::Atom::Atom(File *file)
length = header.toUInt();
- if(length == 1) {
+ if(length == 0) {
+ // The last atom which extends to the end of the file.
+ length = file->length() - offset;
+ }
+ else if(length == 1) {
+ // The atom has a 64-bit length.
const long long longLength = file->readBlock(8).toLongLong();
if(longLength <= LONG_MAX) {
- // The atom has a 64-bit length, but it's actually a 31-bit value or long is 64-bit.
+ // The actual length fits in long. That's always the case if long is 64-bit.
length = static_cast<long>(longLength);
}
else {
@@ -67,6 +72,7 @@ MP4::Atom::Atom(File *file)
return;
}
}
+
if(length < 8) {
debug("MP4: Invalid atom size");
length = 0;