1
1
mirror of https://github.com/wader/fq.git synced 2024-11-26 21:55:57 +03:00

mp4,trun,fuzz: Limit number of constant sample entries

This commit is contained in:
Mattias Wadman 2021-12-12 09:54:48 +01:00
parent 1500fd90e4
commit c149732182

View File

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