From 737d3560ddb3e8e7319a5e9c494ccd749150d675 Mon Sep 17 00:00:00 2001 From: David Howden Date: Wed, 7 Feb 2018 18:29:52 +1100 Subject: [PATCH] mp4: fix panic on invalid encoding Fixes #31 --- mp4.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mp4.go b/mp4.go index 05fcee6..b823c70 100644 --- a/mp4.go +++ b/mp4.go @@ -220,6 +220,10 @@ func readCustomAtom(r io.ReadSeeker, size uint32) (string, uint32, error) { if err != nil { return "", 0, err } + + if len(b) < 4 { + return "", 0, fmt.Errorf("expected at least %d bytes, got %d", 4, len(b)) + } subNames[subName] = string(b[4:]) case "data":