Skip to content

Commit fa56081

Browse files
erictobbee
authored andcommitted
fix: ensure mime box is large enough to read
1 parent 38ff9db commit fa56081

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mp4/mime.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package mp4
22

33
import (
4+
"fmt"
45
"io"
56

67
"github.com/Eyevinn/mp4ff/bits"
@@ -31,6 +32,9 @@ func DecodeMimeSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, err
3132
Version: byte(versionAndFlags >> 24),
3233
Flags: versionAndFlags & flagsMask,
3334
}
35+
if hdr.payloadLen() < 5 {
36+
return nil, fmt.Errorf("mime: box payload size %d less than 5", hdr.payloadLen())
37+
}
3438
rest := sr.ReadBytes(hdr.payloadLen() - 4)
3539
if rest[len(rest)-1] == 0 { // zero-termination
3640
b.ContentType = string(rest[:len(rest)-1])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
go test fuzz v1
2+
[]byte("\x00\x00\x00\fmime0000")

0 commit comments

Comments
 (0)