Skip to content

Commit b8161e8

Browse files
authored
Avoid out of bounds when calculating b.URI[startPos:]
Processing illegal base64 content may cause the program to panic
1 parent 7ed65a3 commit b8161e8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gltf.go

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

33
import (
44
"encoding/base64"
5+
"errors"
56
"strings"
67
"sync"
78
)
@@ -133,6 +134,9 @@ func (b *Buffer) marshalData() ([]byte, error) {
133134
return nil, nil
134135
}
135136
startPos := len(mimetypeApplicationOctet) + 1
137+
if len(b.URI) < startPos {
138+
return nil, errors.New("gltf: Invalid base64 content")
139+
}
136140
sl, err := base64.StdEncoding.DecodeString(b.URI[startPos:])
137141
if len(sl) == 0 || err != nil {
138142
return nil, err

0 commit comments

Comments
 (0)