Skip to content

Commit

Permalink
fix: ensure stsc sample description id isn't 0
Browse files Browse the repository at this point in the history
prevents a panic
  • Loading branch information
eric committed Jan 15, 2025
1 parent 58448ee commit 0d3d1f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mp4/stsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func DecodeStscSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, err
b.Entries[i].FirstSampleNr = accSampleNr

sdi := sr.ReadUint32()
if sdi == 0 {
return nil, fmt.Errorf("stsc sample description id is 0")
}
if i == 0 {
b.singleSampleDescriptionID = sdi
} else {
Expand Down
2 changes: 2 additions & 0 deletions mp4/testdata/fuzz/FuzzDecodeBox/4e3e98fc202208ff
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("\x00\x00\x00(stsc0000\x00\x00\x00\x0200000000\x00\x00\x00\x00000000000000")

0 comments on commit 0d3d1f7

Please sign in to comment.