From 4859accbb038f8db3c3a541d0f3f3f76de75b9fb Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 2 Nov 2021 18:03:16 +0000 Subject: [PATCH] Fix panic in `address.GetKey()` (fixes #860) --- src/address/address.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/address/address.go b/src/address/address.go index 0e2400ed..c7f2eb46 100644 --- a/src/address/address.go +++ b/src/address/address.go @@ -129,7 +129,11 @@ func (a *Address) GetKey() ed25519.PublicKey { bits <<= byte(idx % 8) keyIdx := keyOffset + (idx - addrOffset) bits >>= byte(keyIdx % 8) - key[keyIdx/8] |= bits + idx := keyIdx / 8 + if idx >= len(key) { + break + } + key[idx] |= bits } for idx := range key { key[idx] = ^key[idx]