From d2732a71d85d7068ce0500ff45a3fb9da6f8cebe Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 4 Aug 2021 23:17:50 +0300 Subject: [PATCH] transaction: don't overwrite error and witnesses length check ReadArray() can return some error and we shouldn't overwrite it. At the same time limiting ReadArray() to the number of Signers can make it return wrong error if the number of witnesses actually is bigger than the number of signers, so use MaxAttributes. --- pkg/core/transaction/transaction.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index 61f91ab48..c0344dcc6 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -148,8 +148,8 @@ func (t *Transaction) decodeBinaryNoSize(br *io.BinReader) { if br.Err != nil { return } - br.ReadArray(&t.Scripts, len(t.Signers)) - if len(t.Signers) != len(t.Scripts) { + br.ReadArray(&t.Scripts, MaxAttributes) + if br.Err == nil && len(t.Signers) != len(t.Scripts) { br.Err = fmt.Errorf("%w: %d vs %d", ErrInvalidWitnessNum, len(t.Signers), len(t.Scripts)) return }