Skip to content

Commit

Permalink
check bounds in readAPICFrame
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
dhowden committed Nov 19, 2020
1 parent 4b595ed commit a922134
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions id3v2frames.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,15 @@ func readPICFrame(b []byte) (*Picture, error) {
// Description <text string according to encoding> $00 (00)
// Picture data <binary data>
func readAPICFrame(b []byte) (*Picture, error) {
if len(b) == 0 {
return nil, errors.New("error decoding APIC: invalid encoding")
}
enc := b[0]
mimeDataSplit := bytes.SplitN(b[1:], singleZero, 2)
if len(mimeDataSplit) != 2 {
return nil, errors.New("error decoding APIC: invalid encoding")
}

mimeType := string(mimeDataSplit[0])

b = mimeDataSplit[1]
Expand Down

0 comments on commit a922134

Please sign in to comment.