From 6ff45edbc983b3ad8111e895b4a61e8095fb8b15 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 1 Apr 2021 09:36:29 +0300 Subject: [PATCH] [#65] Do not use integer as a search prefix Even though it is allowed to do so, it can produce invalid search results if key is less than 10 bytes. More at https://github.com/nspcc-dev/neo-go/issues/1873 Signed-off-by: Alex Vanin --- audit/audit_contract.go | 3 ++- reputation/reputation_contract.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/audit/audit_contract.go b/audit/audit_contract.go index 12695d1..400c692 100644 --- a/audit/audit_contract.go +++ b/audit/audit_contract.go @@ -112,7 +112,8 @@ func List() [][]byte { func ListByEpoch(epoch int) [][]byte { ctx := storage.GetReadOnlyContext() - it := storage.Find(ctx, epoch, storage.KeysOnly) + var buf interface{} = epoch + it := storage.Find(ctx, buf.([]byte), storage.KeysOnly) return list(it) } diff --git a/reputation/reputation_contract.go b/reputation/reputation_contract.go index ed6362c..e4640fa 100644 --- a/reputation/reputation_contract.go +++ b/reputation/reputation_contract.go @@ -78,7 +78,8 @@ func GetByID(id []byte) [][]byte { // via GetByID method. func ListByEpoch(epoch int) [][]byte { ctx := storage.GetReadOnlyContext() - it := storage.Find(ctx, epoch, storage.KeysOnly) + var buf interface{} = epoch + it := storage.Find(ctx, buf.([]byte), storage.KeysOnly) var result [][]byte