From ee5692de1544687436b4ed19a0d23c6084b13f17 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Tue, 30 Jul 2024 15:45:46 +0100 Subject: [PATCH] Additional bounds checks. --- spec/fork.go | 4 ++++ spec/transactiontype.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spec/fork.go b/spec/fork.go index dc5f97f..b30bccf 100644 --- a/spec/fork.go +++ b/spec/fork.go @@ -73,5 +73,9 @@ func (d *Fork) UnmarshalJSON(input []byte) error { // String returns a string representation of the item. func (d Fork) String() string { + if int(d) < 0 || int(d) >= len(forkStrings) { + return "unknown" + } + return forkStrings[d] } diff --git a/spec/transactiontype.go b/spec/transactiontype.go index d453aa6..87899f2 100644 --- a/spec/transactiontype.go +++ b/spec/transactiontype.go @@ -64,5 +64,9 @@ func (d *TransactionType) UnmarshalJSON(input []byte) error { // String returns a string representation of the item. func (d TransactionType) String() string { + if int(d) < 0 || int(d) >= len(transactionTypeStrings) { + return "unknown" + } + return transactionTypeStrings[d] }