Skip to content

Commit

Permalink
fix: ensure mime box is large enough to read
Browse files Browse the repository at this point in the history
  • Loading branch information
eric authored and tobbee committed Jan 20, 2025
1 parent 38ff9db commit fa56081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mp4/mime.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mp4

import (
"fmt"
"io"

"github.com/Eyevinn/mp4ff/bits"
Expand Down Expand Up @@ -31,6 +32,9 @@ func DecodeMimeSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, err
Version: byte(versionAndFlags >> 24),
Flags: versionAndFlags & flagsMask,
}
if hdr.payloadLen() < 5 {
return nil, fmt.Errorf("mime: box payload size %d less than 5", hdr.payloadLen())
}
rest := sr.ReadBytes(hdr.payloadLen() - 4)
if rest[len(rest)-1] == 0 { // zero-termination
b.ContentType = string(rest[:len(rest)-1])
Expand Down
2 changes: 2 additions & 0 deletions mp4/testdata/fuzz/FuzzDecodeBox/77cf6e30648805ea
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("\x00\x00\x00\fmime0000")

0 comments on commit fa56081

Please sign in to comment.