From eab6dbd74c1a7bb961b1ba2aadbc782831e19481 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 19 Nov 2024 16:23:35 +0300 Subject: [PATCH] Check if index is within range --- common/transfer_statements.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/transfer_statements.go b/common/transfer_statements.go index cc75e78..eec7e11 100644 --- a/common/transfer_statements.go +++ b/common/transfer_statements.go @@ -77,6 +77,11 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, dates := strings.Split(string(data["txdate"]), "\n") syms := strings.Split(string(data["txsym"]), "\n") + // Check if index is within range + if index < 1 || index > len(senders) { + return "", fmt.Errorf("transaction not found: index %d out of range", index) + } + // Adjust for 0-based indexing i := index - 1 transactionType := "received"