Skip to content

Commit

Permalink
mp4,trun,fuzz: Limit number of constant sample entries
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Dec 12, 2021
1 parent 1500fd9 commit c149732
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions format/mp4/boxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c149732

Please sign in to comment.