mirror of
https://github.com/taglib/taglib.git
synced 2026-07-18 09:20:54 -04:00
MP4: Fix QT chapters excessive sample allocation with invalid stsc (#1379)
See https://mail.kde.org/pipermail/taglib-devel/2026-July/003122.html --------- Co-authored-by: Lee, Brian J <hibrian827@gatech.edu>
This commit is contained in:
@@ -825,6 +825,9 @@ namespace
|
||||
const std::vector<unsigned int> chunkOffsets = readStco(file, chapterTrak);
|
||||
if(chunkOffsets.empty())
|
||||
return {};
|
||||
// Sample count cannot be > file length / 4 as every sample consumes 4 bytes in stsz
|
||||
if(sizeInfo.sampleCount == 0 || sizeInfo.sampleCount > file->length() / 4)
|
||||
return {};
|
||||
|
||||
// Read stsc entries
|
||||
struct StscEntry {
|
||||
@@ -875,6 +878,9 @@ namespace
|
||||
}
|
||||
|
||||
unsigned int offsetInChunk = 0;
|
||||
if(samplesInChunk > sizeInfo.sampleCount - sampleIndex)
|
||||
samplesInChunk = sizeInfo.sampleCount - sampleIndex;
|
||||
|
||||
for(unsigned int s = 0; s < samplesInChunk; ++s) {
|
||||
sampleOffsets.push_back(chunkOffsets[chunkIdx] + offsetInChunk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user