mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
fix(type): check buffer length
This commit is contained in:
parent
5e79759297
commit
ac42bba851
1 changed files with 3 additions and 0 deletions
3
type.go
3
type.go
|
|
@ -61,6 +61,9 @@ var SupportedImageTypes = map[ImageType]bool{
|
|||
|
||||
// isBinary checks if the given buffer is a binary file.
|
||||
func isBinary(buf []byte) bool {
|
||||
if len(buf) < 24 {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < 24; i++ {
|
||||
charCode, _ := utf8.DecodeRuneInString(string(buf[i]))
|
||||
if charCode == 65533 || charCode <= 8 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue