From d365c81f39a2c55b0df7d025bd99a4126faecad5 Mon Sep 17 00:00:00 2001 From: Joshua Foster Date: Mon, 1 Apr 2024 14:45:10 -0400 Subject: [PATCH] check for negative numSignatures to prevent panic --- transaction.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transaction.go b/transaction.go index e64ab4b0..73dd76ca 100644 --- a/transaction.go +++ b/transaction.go @@ -483,6 +483,9 @@ func (tx *Transaction) UnmarshalWithDecoder(decoder *bin.Decoder) (err error) { if err != nil { return fmt.Errorf("unable to read numSignatures: %w", err) } + if numSignatures < 0 { + return fmt.Errorf("numSignatures %d is negative", numSignatures) + } if numSignatures > decoder.Remaining()/64 { return fmt.Errorf("numSignatures %d is too large for remaining bytes %d", numSignatures, decoder.Remaining()) }