From f4e8aa21b883b4e7fbedcf35893fa379ef57a986 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 19 Apr 2017 16:18:31 -0700 Subject: [PATCH] lnwire: enforce a max limit on an outpoint's index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit implements the constraint on an outpoint’s index as defined within the specification. --- lnwire/lnwire.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnwire/lnwire.go b/lnwire/lnwire.go index 486dffdf8..2b114b4de 100644 --- a/lnwire/lnwire.go +++ b/lnwire/lnwire.go @@ -191,6 +191,12 @@ func writeElement(w io.Writer, element interface{}) error { return err } + if e.Index > math.MaxUint16 { + return fmt.Errorf("index for outpoint (%v) is "+ + "greater than max index of %v", e.Index, + math.MaxUint16) + } + var idx [2]byte binary.BigEndian.PutUint16(idx[:], uint16(e.Index)) if _, err := w.Write(idx[:]); err != nil {