From 22b9366046be96135875852a673b937f629781dd Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Mon, 8 Oct 2018 17:40:05 +0100 Subject: [PATCH] Check for excess data when unmarshaling binary data --- marshal.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/marshal.go b/marshal.go index 7bfb99b..8e28421 100644 --- a/marshal.go +++ b/marshal.go @@ -110,7 +110,10 @@ func (m *Macaroon) UnmarshalBinary(data []byte) error { // Copy the data to avoid retaining references to it // in the internal data structures. data = append([]byte(nil), data...) - _, err := m.parseBinary(data) + rest, err := m.parseBinary(data) + if len(rest) != 0 { + return fmt.Errorf("trailing binary data") + } return err }