Skip to content

Commit

Permalink
mp4: fix panic on invalid encoding
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
dhowden committed Feb 7, 2018
1 parent 737d356 commit 1582ebc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (m metadataMP4) readAtomData(r io.ReadSeeker, name string, size uint32) err
return err
}

if len(b) < 8 {
return fmt.Errorf("invalid encoding: expected at least %d bytes, got %d", 8, len(b))
}

// "data" + size (4 bytes each)
b = b[8:]

Expand Down Expand Up @@ -222,7 +226,7 @@ func readCustomAtom(r io.ReadSeeker, size uint32) (string, uint32, error) {
}

if len(b) < 4 {
return "", 0, fmt.Errorf("expected at least %d bytes, got %d", 4, len(b))
return "", 0, fmt.Errorf("invalid encoding: expected at least %d bytes, got %d", 4, len(b))
}
subNames[subName] = string(b[4:])

Expand Down

0 comments on commit 1582ebc

Please sign in to comment.