diff --git a/format/mp4/boxes.go b/format/mp4/boxes.go index 02e85d0e..6be8fcdc 100644 --- a/format/mp4/boxes.go +++ b/format/mp4/boxes.go @@ -12,6 +12,9 @@ import ( "github.com/wader/fq/pkg/scalar" ) +// TODO: keep track of list of sampleSize/entries instead and change sample read code +const maxSampleEntryCount = 10_000_000 + var boxAliases = map[string]string{ "styp": "ftyp", } @@ -539,10 +542,8 @@ func init() { }) } else { if ctx.currentTrack != nil { - // TODO: keep track of list of sampleSize/entries instead and change sample read code - const maxEntryCount = 10_000_000 - if entryCount > maxEntryCount { - d.Errorf("too many constant stsz entries %d > %d", entryCount, maxEntryCount) + if entryCount > maxSampleEntryCount { + d.Errorf("too many constant stsz entries %d > %d", entryCount, maxSampleEntryCount) } for i := uint64(0); i < entryCount; i++ { ctx.currentTrack.stsz = append(ctx.currentTrack.stsz, uint32(sampleSize)) @@ -765,6 +766,10 @@ func init() { d.FieldU32("first_sample_flags") } + if sampleCount > maxSampleEntryCount { + d.Errorf("too many constant trun entries %d > %d", sampleCount, maxSampleEntryCount) + } + d.FieldArray("samples", func(d *decode.D) { for i := uint64(0); i < sampleCount; i++ { sampleSize := m.defaultSampleSize